public int fileUpload(MultipartFile file, HttpServletRequest request) throws IOException {
String filePath = request.getSession().getServletContext().getRealPath("/");
String path = filePath.substring(0, filePath.indexOf("target"));
String filename = file.getOriginalFilename();
//第一次如果没有保存图片的文件夹创建文件夹
String path1 = path + "src/main/webapp/images/";
String path_img = path1 + filename;
File dest = new File(path_img);
if (!dest.getParentFile().exists()) {
dest.getParentFile().mkdirs();
}
file.transferTo(dest);
try {
//逻辑判断
} catch (Exception e) {
e.printStackTrace();
return 1;
}
}
String filePath = request.getSession().getServletContext().getRealPath("/");
String path = filePath.substring(0, filePath.indexOf("target"));
String filename = file.getOriginalFilename();
//第一次如果没有保存图片的文件夹创建文件夹
String path1 = path + "src/main/webapp/images/";
String path_img = path1 + filename;
File dest = new File(path_img);
if (!dest.getParentFile().exists()) {
dest.getParentFile().mkdirs();
}
file.transferTo(dest);
try {
//逻辑判断
} catch (Exception e) {
e.printStackTrace();
return 1;
}
}