From 687f95c7e91e2d49c147518e4d9bdb7dcdb86ae1 Mon Sep 17 00:00:00 2001 From: eatmoreapple <15055461510@163.com> Date: Thu, 11 Nov 2021 15:19:57 +0800 Subject: [PATCH] :poop: update getFileExt --- parser.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/parser.go b/parser.go index 0d5c3ec..af013cd 100644 --- a/parser.go +++ b/parser.go @@ -7,6 +7,7 @@ import ( "math/rand" "mime/multipart" "net/http" + "path/filepath" "reflect" "strconv" "strings" @@ -63,11 +64,11 @@ func GetFileContentType(file multipart.File) (string, error) { } func getFileExt(name string) string { - results := strings.Split(name, ".") - if len(results) == 1 { - return "undefined" + ext := filepath.Ext(name) + if len(ext) == 0 { + ext = "undefined" } - return results[len(results)-1] + return ext } const (