Fixed the "bad file" bugs #7
This commit is contained in:
parent
b1d28b3046
commit
3801232d93
@ -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 {
|
||||
|
@ -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 {
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user