|
|
@ -5,7 +5,6 @@ import ( |
|
|
|
"beeblog/service" |
|
|
|
"crypto/md5" |
|
|
|
"fmt" |
|
|
|
"github.com/beego/beego/v2/core/config" |
|
|
|
beego "github.com/beego/beego/v2/server/web" |
|
|
|
"math/rand" |
|
|
|
"os" |
|
|
@ -46,7 +45,7 @@ func (this *FileController) Upload() { |
|
|
|
} |
|
|
|
//创建目录
|
|
|
|
urlDir := time.Now().Format("2006/01/02/") |
|
|
|
uploadDir, _ := config.String("uploadDir") |
|
|
|
uploadDir, _ := beego.AppConfig.String("uploadDir") |
|
|
|
uploadDir = uploadDir + urlDir |
|
|
|
err := os.MkdirAll(uploadDir, 777) |
|
|
|
if err != nil { |
|
|
@ -69,7 +68,7 @@ func (this *FileController) Upload() { |
|
|
|
this.ServeJSON() |
|
|
|
return |
|
|
|
} |
|
|
|
imgUrlPrefix, _ := config.String("imgUrlPrefix") |
|
|
|
imgUrlPrefix, _ := beego.AppConfig.String("imgUrlPrefix") |
|
|
|
urlDir = imgUrlPrefix + urlDir |
|
|
|
this.Data["json"] = models.ReurnData("", urlDir) |
|
|
|
this.ServeJSON() |
|
|
@ -109,7 +108,7 @@ func (this *FileController) HeadImgUpload() { |
|
|
|
} |
|
|
|
//创建目录
|
|
|
|
urlDir := time.Now().Format("2006/01/02/") |
|
|
|
uploadDir, _ := config.String("uploadDir") |
|
|
|
uploadDir, _ := beego.AppConfig.String("uploadDir") |
|
|
|
uploadDir = uploadDir + urlDir |
|
|
|
err := os.MkdirAll(uploadDir, 777) |
|
|
|
if err != nil { |
|
|
@ -132,7 +131,7 @@ func (this *FileController) HeadImgUpload() { |
|
|
|
this.ServeJSON() |
|
|
|
return |
|
|
|
} |
|
|
|
imgUrlPrefix, _ := config.String("imgUrlPrefix") |
|
|
|
imgUrlPrefix, _ := beego.AppConfig.String("imgUrlPrefix") |
|
|
|
urlDir = imgUrlPrefix + urlDir |
|
|
|
user := &models.User{Id: uid.(int64), Headimg: urlDir} |
|
|
|
userSerivce := service.UserService{} |
|
|
|