caipin 4 years ago
parent
commit
f2b807b8e8
1 changed files with 2 additions and 1 deletions
  1. 2 1
      web/api/upload_api.go

+ 2 - 1
web/api/upload_api.go

@@ -62,6 +62,7 @@ func (c *UploadApi) Post() {
 	UploadAt := fmt.Sprintf("%d", time.Now().UnixNano())
 
 	Location := conf.MergeLocalRootDir + UploadAt + head.Filename // 存储地址
+	webLocation := "/public/" + UploadAt + head.Filename
 	newFile, err := os.Create(Location)
 	if err != nil {
 		log.Printf("Failed to create file, err:%s\n", err.Error())
@@ -97,7 +98,7 @@ func (c *UploadApi) Post() {
 
 	ext := strings.Join(head.Header["Content-Type"], "")
 
-	id, err = c.ServiceContract.SaveUpload(Location, head.Filename, ext)
+	id, err = c.ServiceContract.SaveUpload(webLocation, head.Filename, ext)
 	if err != nil {
 		errCode = -6
 		return