文件上传

This commit is contained in:
JeromeSoar 2022-04-24 18:05:54 +08:00
parent df23750203
commit 145238ea96
2 changed files with 3 additions and 2 deletions

View File

@ -56,7 +56,8 @@ public class FileController {
}) })
public CommonResult<String> uploadFile(@RequestParam("file") MultipartFile file) throws Exception { public CommonResult<String> uploadFile(@RequestParam("file") MultipartFile file) throws Exception {
String path = DateUtil.format(new Date(), "yyyy/MM/dd/") + file.getOriginalFilename(); 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") @DeleteMapping("/delete")

View File

@ -127,7 +127,7 @@ export default {
}, },
// //
handleUploadSuccess(res) { 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) { if (this.uploadList.length === this.number) {
this.fileList = this.fileList.concat(this.uploadList); this.fileList = this.fileList.concat(this.uploadList);
this.uploadList = []; this.uploadList = [];