|
@@ -105,13 +105,15 @@ public class FileUploadUtils
|
|
|
{
|
|
|
throw new FileNameLengthLimitExceededException(FileUploadUtils.DEFAULT_FILE_NAME_LENGTH);
|
|
|
}
|
|
|
-
|
|
|
+ //校验文件大小校验和后缀名
|
|
|
assertAllowed(file, allowedExtension);
|
|
|
-
|
|
|
+ //编码文件名
|
|
|
String fileName = extractFilename(file);
|
|
|
-
|
|
|
+ //根据目录创建文件夹
|
|
|
File desc = getAbsoluteFile(baseDir, fileName);
|
|
|
+ //上传
|
|
|
file.transferTo(desc);
|
|
|
+ //组合上传地址
|
|
|
String pathFileName = getPathFileName(baseDir, fileName);
|
|
|
return pathFileName;
|
|
|
}
|
|
@@ -167,7 +169,9 @@ public class FileUploadUtils
|
|
|
throw new FileSizeLimitExceededException(DEFAULT_MAX_SIZE / 1024 / 1024);
|
|
|
}
|
|
|
|
|
|
+ //获取文件原始名称
|
|
|
String fileName = file.getOriginalFilename();
|
|
|
+ //获取文件名的后缀
|
|
|
String extension = getExtension(file);
|
|
|
if (allowedExtension != null && !isAllowedExtension(extension, allowedExtension))
|
|
|
{
|