From 63da33a8cafcbd31c3e3bbedbd34ad71fb65d289 Mon Sep 17 00:00:00 2001 From: xoy Date: Sat, 28 Jan 2023 23:43:07 +0100 Subject: [PATCH] working on file upload --- http.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/http.go b/http.go index 5dac176..0bb8f85 100644 --- a/http.go +++ b/http.go @@ -24,20 +24,22 @@ func httpHandleFuncWithPOST(urlPath string, filepath string, contentType string) s.data = "null" http.HandleFunc("/"+urlPath, func(w http.ResponseWriter, r *http.Request) { if r.Method == "POST" { + r.ParseMultipartForm(10 << 20) err := r.ParseForm() errorPanic(err) if filepath == "./web/pages/admin/dashboard.html" { title := r.FormValue("title") description := r.FormValue("description") - files := r.FormValue("media") + media, media_header, err := r.FormFile("media") + errorPanic(err) date := r.FormValue("date") - if title != "" && description != "" && files != "" && date != "" { + if title != "" && description != "" && media != nil && date != "" { logger("----------------POST----------------") logger("title: " + title) logger("descrtiption: " + description) - logger("media: " + files) + logger("media: " + media_header.Filename) logger("date: " + date) logger("----------------POST END----------------") }