fehlerbehebung
This commit is contained in:
parent
aef502e2ed
commit
fea054fd4a
43
http.go
43
http.go
|
@ -3,6 +3,7 @@ package main
|
||||||
import (
|
import (
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -25,22 +26,40 @@ func httpHandleFuncWithPOST(urlPath string, filepath string, contentType string)
|
||||||
http.HandleFunc("/"+urlPath, func(w http.ResponseWriter, r *http.Request) {
|
http.HandleFunc("/"+urlPath, func(w http.ResponseWriter, r *http.Request) {
|
||||||
if r.Method == "POST" {
|
if r.Method == "POST" {
|
||||||
r.ParseMultipartForm(10 << 20)
|
r.ParseMultipartForm(10 << 20)
|
||||||
err := r.ParseForm()
|
err := r.ParseMultipartForm(200000)
|
||||||
errorPanic(err)
|
errorPanic(err)
|
||||||
|
|
||||||
if filepath == "./web/pages/admin/dashboard.html" {
|
formdata := r.MultipartForm
|
||||||
title := r.FormValue("title")
|
|
||||||
description := r.FormValue("description")
|
|
||||||
media, media_header, err := r.FormFile("media")
|
|
||||||
errorPanic(err)
|
|
||||||
date := r.FormValue("date")
|
|
||||||
|
|
||||||
if title != "" && description != "" && media != nil && date != "" {
|
files := formdata.File["multiplefiles"] // grab the filenames
|
||||||
|
|
||||||
|
logger("files uploaded successfully : ")
|
||||||
|
|
||||||
|
for i, _ := range files { // loop through the files one by one
|
||||||
|
file, err := files[i].Open()
|
||||||
|
errorPanic(err)
|
||||||
|
|
||||||
|
out, err := os.Create("./web/images/" + files[i].Filename)
|
||||||
|
errorPanic(err)
|
||||||
|
|
||||||
|
_, err = io.Copy(out, file)
|
||||||
|
errorPanic(err)
|
||||||
|
|
||||||
|
logger(files[i].Filename)
|
||||||
|
}
|
||||||
|
|
||||||
|
if filepath == "./web/pages/admin/dashboard.html" {
|
||||||
|
title := formdata.Value["title"]
|
||||||
|
description := formdata.Value["description"]
|
||||||
|
media := formdata.File["media"]
|
||||||
|
date := formdata.Value["date"]
|
||||||
|
|
||||||
|
if title[0] != "" && description[0] != "" && media != nil && date[0] != "" {
|
||||||
logger("----------------POST----------------")
|
logger("----------------POST----------------")
|
||||||
logger("title: " + title)
|
logger("title: " + title[0])
|
||||||
logger("descrtiption: " + description)
|
logger("descrtiption: " + description[0])
|
||||||
logger("media: " + media_header.Filename)
|
logger("media: " + string(len(media)))
|
||||||
logger("date: " + date)
|
logger("date: " + date[0])
|
||||||
logger("----------------POST END----------------")
|
logger("----------------POST END----------------")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue