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