fix扩展名可能为大写

This commit is contained in:
2023-02-25 21:25:34 +08:00
parent 4048ee982b
commit 0dc3aed4fe

View File

@@ -3,10 +3,11 @@ package util
import ( import (
"errors" "errors"
"path/filepath" "path/filepath"
"strings"
) )
func ValidateFilename(filename string) error { func ValidateFilename(filename string) error {
switch filepath.Ext(filename) { switch filepath.Ext(strings.ToLower(filename)) {
case ".pdf", ".doc", ".jpg", ".gif", ".png", ".jpeg", case ".pdf", ".doc", ".jpg", ".gif", ".png", ".jpeg",
".docx", ".xls", ".xlsx", ".zip", ".rar", ".7z", ".txt": ".docx", ".xls", ".xlsx", ".zip", ".rar", ".7z", ".txt":
return nil return nil