|
@ -40,7 +40,8 @@ func (this *FileController) Upload() { |
|
|
return |
|
|
return |
|
|
} |
|
|
} |
|
|
//创建目录
|
|
|
//创建目录
|
|
|
uploadDir := "static/upload/" + time.Now().Format("2006/01/02/") |
|
|
urlDir := time.Now().Format("2006/01/02/") |
|
|
|
|
|
uploadDir := "/opt/filetom/webapps/itstack/" + urlDir |
|
|
err := os.MkdirAll(uploadDir, 777) |
|
|
err := os.MkdirAll(uploadDir, 777) |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
this.Data["json"] = models.ReurnError(500, "") |
|
|
this.Data["json"] = models.ReurnError(500, "") |
|
@ -53,6 +54,7 @@ func (this *FileController) Upload() { |
|
|
hashName := md5.Sum([]byte( time.Now().Format("2006_01_02_15_04_05_") + randNum )) |
|
|
hashName := md5.Sum([]byte( time.Now().Format("2006_01_02_15_04_05_") + randNum )) |
|
|
fileName := fmt.Sprintf("%x", hashName) + ext |
|
|
fileName := fmt.Sprintf("%x", hashName) + ext |
|
|
fpath := uploadDir + fileName |
|
|
fpath := uploadDir + fileName |
|
|
|
|
|
urlDir += fileName |
|
|
defer f.Close() //关闭上传的文件,不然的话会出现临时文件不能清除的情况
|
|
|
defer f.Close() //关闭上传的文件,不然的话会出现临时文件不能清除的情况
|
|
|
err = this.SaveToFile(filename, fpath) |
|
|
err = this.SaveToFile(filename, fpath) |
|
|
if err != nil { |
|
|
if err != nil { |
|
@ -61,6 +63,7 @@ func (this *FileController) Upload() { |
|
|
this.ServeJSON() |
|
|
this.ServeJSON() |
|
|
return |
|
|
return |
|
|
} |
|
|
} |
|
|
|
|
|
urlDir = "https://aiprose.com/foss/" + urlDir |
|
|
this.Data["json"] = models.ReurnData("", fpath) |
|
|
this.Data["json"] = models.ReurnData("", fpath) |
|
|
this.ServeJSON() |
|
|
this.ServeJSON() |
|
|
return |
|
|
return |
|
@ -128,7 +131,6 @@ func (this *FileController) HeadImgUpload() { |
|
|
this.ServeJSON() |
|
|
this.ServeJSON() |
|
|
return |
|
|
return |
|
|
} |
|
|
} |
|
|
this.SetSession("headimg", urlDir) |
|
|
|
|
|
this.Data["json"] = models.ReurnData("", urlDir) |
|
|
this.Data["json"] = models.ReurnData("", urlDir) |
|
|
this.ServeJSON() |
|
|
this.ServeJSON() |
|
|
return |
|
|
return |
|
|