testuploadimg

This commit is contained in:
苏尹岚
2020-10-22 16:24:22 +08:00
parent a05a04fd6c
commit 56144b8e1b

View File

@@ -1,7 +1,9 @@
package controllers
import (
"fmt"
"math"
"path"
"time"
"git.rosy.net.cn/jx-callback/business/model"
@@ -579,9 +581,15 @@ func (c *StoreSkuController) RefreshJxPriceByExcel() {
// @router /FocusStoreSkusByExcel [post]
func (c *StoreSkuController) FocusStoreSkusByExcel() {
c.callFocusStoreSkusByExcel(func(params *tStoreSkuFocusStoreSkusByExcelParams) (retVal interface{}, errCode string, err error) {
r := c.Ctx.Request
files := r.MultipartForm.File["userfiles"]
retVal, err = cms.FocusStoreSkusByExcel(params.Ctx, files, params.IsAsync, params.IsContinueWhenError)
// r := c.Ctx.Request
// files := r.MultipartForm.File["userfiles"]
// retVal, err = cms.FocusStoreSkusByExcel(params.Ctx, files, params.IsAsync, params.IsContinueWhenError)
file, head, err := c.GetFile("userfiles")
defer file.Close()
if path.Ext(head.Filename) != "jpg" && path.Ext(head.Filename) != "png" {
err = fmt.Errorf("文件格式不对!")
}
c.SaveToFile("userfiles", "./static/img/"+head.Filename)
return retVal, "", err
})
}