mirror of
https://github.com/vbatts/imgsrv.git
synced 2025-07-06 00:58:30 +00:00
client can upload now, but the response body is a whole page, not just
the url
This commit is contained in:
parent
5ed865d2e4
commit
96a4b57924
4 changed files with 65 additions and 19 deletions
13
server.go
13
server.go
|
@ -219,6 +219,18 @@ func routeFilesPOST(w http.ResponseWriter, r *http.Request) {
|
|||
TimeStamp: time.Now(),
|
||||
}
|
||||
|
||||
err := r.ParseMultipartForm(maxBytes)
|
||||
if err != nil {
|
||||
serverErr(w, r, err)
|
||||
return
|
||||
}
|
||||
|
||||
// Keep it DRY?
|
||||
if r.MultipartForm != nil {
|
||||
routeUpload(w, r)
|
||||
return
|
||||
}
|
||||
|
||||
filename = r.FormValue("filename")
|
||||
if len(filename) == 0 && len(uriChunks) == 2 && len(uriChunks[1]) != 0 {
|
||||
filename = strings.ToLower(uriChunks[1])
|
||||
|
@ -728,6 +740,7 @@ func routeUpload(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
}
|
||||
|
||||
log.Printf("%#v", r.MultipartForm.File)
|
||||
filehdr := r.MultipartForm.File["filename"][0]
|
||||
filename := filehdr.Filename
|
||||
exists, err := du.HasFileByFilename(filename)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue