diff --git a/member_routes.go b/member_routes.go index 14029d42..b77e1c18 100644 --- a/member_routes.go +++ b/member_routes.go @@ -319,6 +319,9 @@ func routeAccountEditAvatarSubmit(w http.ResponseWriter, r *http.Request, user c var filename, ext string for _, fheaders := range r.MultipartForm.File { for _, hdr := range fheaders { + if hdr.Filename == "" { + continue + } infile, err := hdr.Open() if err != nil { return common.LocalError("Upload failed", w, r, user) @@ -364,6 +367,9 @@ func routeAccountEditAvatarSubmit(w http.ResponseWriter, r *http.Request, user c } } } + if ext == "" { + return common.LocalError("No file", w, r, user) + } err := user.ChangeAvatar("." + ext) if err != nil { diff --git a/routes/reply.go b/routes/reply.go index 414235eb..1d6ddafe 100644 --- a/routes/reply.go +++ b/routes/reply.go @@ -50,6 +50,9 @@ func CreateReplySubmit(w http.ResponseWriter, r *http.Request, user common.User) } for _, file := range files { + if file.Filename == "" { + continue + } log.Print("file.Filename ", file.Filename) extarr := strings.Split(file.Filename, ".") if len(extarr) < 2 { diff --git a/routes/topic.go b/routes/topic.go index d2037052..5906c59f 100644 --- a/routes/topic.go +++ b/routes/topic.go @@ -422,6 +422,9 @@ func CreateTopicSubmit(w http.ResponseWriter, r *http.Request, user common.User) } for _, file := range files { + if file.Filename == "" { + continue + } common.DebugLog("file.Filename ", file.Filename) extarr := strings.Split(file.Filename, ".") if len(extarr) < 2 {