@@ 30,6 30,15 @@ func authCheck(user string, key string) bool {
return false
}
+func extCheck(extension string) bool {
+ switch extension {
+ case ".png", ".jpg", ".zip", ".tar", ".gz", ".pdf", ".txt", ".aac",
+ ".mp4", ".mkv", ".mp3", ".flac", ".ogg":
+ return true
+ }
+ return false
+}
+
func uploadHandler(w http.ResponseWriter, r *http.Request) {
if r.Method != "POST" {
http.Error(w, "403 - Access Denied upload GET", http.StatusForbidden)
@@ 64,7 73,7 @@ func uploadHandler(w http.ResponseWriter, r *http.Request) {
}
ext := path.Ext(header.Filename)
- if ext != ".png" && ext != ".jpg" && ext != ".zip" && ext != ".txt" && ext != ".gz" && ext != ".pdf" {
+ if !extCheck(ext) {
fmt.Fprintf(w, "Invalid File Extension\n")
return
}