working on file upload

This commit is contained in:
xoy 2023-01-28 23:43:07 +01:00
parent bf33e34241
commit 9e4d618b5c
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----------------")
}