1、控制器代码:
//上传图片
@PostMapping("/imgOtherUpload")
public ResponseResult uploadOtherImg(@RequestParam("multipartFile") MultipartFile multipartFile,Integer checkUserId) {
try {
if (multipartFile.isEmpty() || StringUtils.isBlank( multipartFile.getOriginalFilename() )) {
return new ResponseResult( CommonCode.INVALID_PARAM );
}
String contentType = multipartFile.getContentType();
if (!contentType.contains( "image" )) {
return new ResponseResult( CommonCode.INVALID_PARAM );
}
String root_fileName = multipartFile.getOriginalFilename();
logger.info( "上传图片:name={},type={}", root_fileName, contentType );
String date = DateFormatUtils.format( new Date(), "/yyyy/MM/dd/" );
String directoryName = "other";
String filePath =