working on file upload

This commit is contained in:
xoy 2023-01-28 23:43:07 +01:00
parent 2de0705ecc
commit 63da33a8ca
1 changed files with 5 additions and 3 deletions

View File

@ -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----------------")
}