From ec27b01403fe85824a90fad5a5c746c6751a3dea Mon Sep 17 00:00:00 2001 From: Expand-sys Date: Wed, 17 Aug 2022 22:01:22 +1000 Subject: [PATCH] nothing working yet but making small progress --- main.go | 23 ++++++++++++++++++++--- static/index.html | 22 ++++++++++++---------- 2 files changed, 32 insertions(+), 13 deletions(-) diff --git a/main.go b/main.go index e24035d..c7e505b 100644 --- a/main.go +++ b/main.go @@ -4,8 +4,10 @@ import ( "fmt" "image" "image/color" + "io" "log" "net/http" + "os" "github.com/disintegration/imaging" "github.com/fogleman/gg" @@ -25,13 +27,28 @@ func routeHandler(w http.ResponseWriter, r *http.Request) { } func formHandler(w http.ResponseWriter, r *http.Request) { - if err := r.ParseMultipartForm(2048); err != nil { + file, handler, err := r.FormFile("file") + fileName := r.FormValue("file_name") + if err != nil { + panic(err) + } + defer file.Close() + + f, err := os.OpenFile(handler.Filename, os.O_WRONLY|os.O_CREATE, 0666) + if err != nil { + panic(err) + } + defer f.Close() + _, _ = io.WriteString(w, "File "+fileName+" Uploaded successfully") + _, _ = io.Copy(f, file) + + if err := r.ParseMultipartForm(8192); err != nil { fmt.Fprintf(w, "ParseMultipartForm() err: %v", err) return } fmt.Fprintf(w, "POST request successful") - //uncommentfile := r.FormValue("file") - //uncommenttext := r.FormValue("text") + + //text := r.FormValue("text") } diff --git a/static/index.html b/static/index.html index 77c8cb7..af50972 100644 --- a/static/index.html +++ b/static/index.html @@ -1,5 +1,5 @@ - + @@ -11,15 +11,17 @@ - - -
-

a dumb lil elden ring generator i made (ALPHA)

-

-

Enter your text

- -
-
+
+ + +
+

a dumb lil elden ring generator i made (ALPHA)

+

+

Enter your text

+ + +
+

More options coming soon same with some styling to make it not look like another of my projects