From ba803bba0d27cb15a34f25300f15ca93ef6d1651 Mon Sep 17 00:00:00 2001 From: tom <769762046@qq.com> Date: Mon, 12 Jun 2017 15:33:46 +0800 Subject: [PATCH 1/2] fix get the Chinese file bug --- controllers/default.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/controllers/default.go b/controllers/default.go index 1e1c579..3f34aff 100644 --- a/controllers/default.go +++ b/controllers/default.go @@ -56,7 +56,8 @@ func (this *UploadController) Post() { } //生成新的文件名 filename := h.Filename - ext := utils.SubString(filename, strings.LastIndex(filename, "."), 5) + //ext := utils.SubString(filename, strings.LastIndex(filename, "."), 5) + ext := path.Ext(filename) filename = utils.GetGuid() + ext if err != nil { @@ -113,7 +114,8 @@ func (this *UploadMultiController) Post() { filename := files[i].Filename resfilename += utils.GetFileSuffix(filename) + "||" - ext := utils.SubString(filename, strings.LastIndex(filename, "."), 5) + //ext := utils.SubString(filename, strings.LastIndex(filename, "."), 5) + ext := path.Ext(filename) filename = utils.GetGuid() + ext dst, err := os.Create(dir + "/" + filename) From a65aa025683c328898f6d2ec6ac909e049f7e8de Mon Sep 17 00:00:00 2001 From: tom <769762046@qq.com> Date: Mon, 12 Jun 2017 15:38:11 +0800 Subject: [PATCH 2/2] add path package --- controllers/default.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/controllers/default.go b/controllers/default.go index 3f34aff..dc8d6e7 100644 --- a/controllers/default.go +++ b/controllers/default.go @@ -4,7 +4,7 @@ import ( //"fmt" "io" - + "path" "github.com/lock-upme/beegoblog/utils" //"net/http" "os"