|
@@ -26,7 +26,7 @@ public class UploadController {
|
|
|
@PostMapping("/images")
|
|
|
public ReturnMsg upload(@RequestParam("images") MultipartFile file) {
|
|
|
//图片校验(图片是否为空,图片大小,上传的是不是图片、图片类型(例如只能上传png)等等)
|
|
|
- String savePath = File.separator + "src" + File.separator + "main" + File.separator + "resources" + File.separator + "static" + File.separator + "images" + File.separator;
|
|
|
+ String savePath = File.separator +"upload"+File.separator+ "images" + File.separator;
|
|
|
if (file.isEmpty()) {
|
|
|
return ReturnMsg.fail("图片上传失败");
|
|
|
}
|
|
@@ -44,14 +44,14 @@ public class UploadController {
|
|
|
String newName = uuid + ext;
|
|
|
//拼接图片上传的路径 url+图片名
|
|
|
ApplicationHome applicationHome = new ApplicationHome(this.getClass());
|
|
|
- String pre = applicationHome.getDir().getParentFile().getParentFile().getAbsolutePath() + savePath;
|
|
|
- String path = pre + newName;
|
|
|
+ //String pre = applicationHome.getDir().getParentFile().getParentFile().getAbsolutePath() + savePath;
|
|
|
+ String path = savePath + newName;
|
|
|
try {
|
|
|
file.transferTo(new File(path));
|
|
|
} catch (IOException e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
- return ReturnMsg.ok("/images/" + newName);
|
|
|
+ return ReturnMsg.ok("/image/" + newName);
|
|
|
} else {
|
|
|
return ReturnMsg.fail("文件类型符合要求");
|
|
|
}
|