Browse Source

文件上传

JeromeSoar 3 years ago
parent
commit
145238ea96

+ 2 - 1
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/file/FileController.java

@@ -56,7 +56,8 @@ public class FileController {
     })
     public CommonResult<String> uploadFile(@RequestParam("file") MultipartFile file) throws Exception {
         String path = DateUtil.format(new Date(), "yyyy/MM/dd/") + file.getOriginalFilename();
-        return success(fileService.createFile(path, IoUtil.readBytes(file.getInputStream())));
+        String file1 = fileService.createFile(path, IoUtil.readBytes(file.getInputStream()));
+        return success(file1);
     }
 
     @DeleteMapping("/delete")

+ 1 - 1
yudao-ui-admin/src/components/ImageUpload/index.vue

@@ -127,7 +127,7 @@ export default {
     },
     // 上传成功回调
     handleUploadSuccess(res) {
-      this.uploadList.push({ name: res.fileName, url: res.fileName });
+      this.uploadList.push({ name: res.data, url: res.data });
       if (this.uploadList.length === this.number) {
         this.fileList = this.fileList.concat(this.uploadList);
         this.uploadList = [];