add force_upload to mimetype detection back again
This commit is contained in:
parent
041922ea6d
commit
6624c5a989
1 changed files with 8 additions and 6 deletions
|
@ -144,12 +144,15 @@ func uploadHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
forceUpload := r.FormValue("force_upload")
|
||||||
|
if forceUpload != "true" {
|
||||||
mimeType := http.DetectContentType(buffer)
|
mimeType := http.DetectContentType(buffer)
|
||||||
if !strings.HasPrefix(mimeType, "image/") && !strings.HasPrefix(mimeType, "text/xml") && !strings.HasPrefix(mimeType, "image/svg+xml") {
|
if !strings.HasPrefix(mimeType, "image/") && !strings.HasPrefix(mimeType, "text/xml") && !strings.HasPrefix(mimeType, "image/svg+xml") {
|
||||||
http.Error(w, "Nur Bild-Uploads sind erlaubt", http.StatusBadRequest)
|
http.Error(w, "Nur Bild-Uploads sind erlaubt", http.StatusBadRequest)
|
||||||
log.Printf("Versuch, eine Nicht-Bild-Datei hochzuladen: %v", mimeType)
|
log.Printf("Versuch, eine Nicht-Bild-Datei hochzuladen: %v", mimeType)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
_, err = file.Seek(0, io.SeekStart)
|
_, err = file.Seek(0, io.SeekStart)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -158,7 +161,6 @@ func uploadHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
forceUpload := r.FormValue("force_upload")
|
|
||||||
forceName := r.FormValue("force_name")
|
forceName := r.FormValue("force_name")
|
||||||
|
|
||||||
var filename string
|
var filename string
|
||||||
|
|
Loading…
Reference in a new issue