多文件上传到本地服务器
支持单个或者多个文件上传, 可以直接拷贝使用运行
Controller:
@Value("${profile}")
String SPURL;
@RequestMapping(value = "/batch/upload",method = RequestMethod.POST)
public @ResponseBody String uploads(HttpServletRequest request,MultipartFile[] file) {
try {
//上传目录地址
String uploadDir = SPURL;
//如果目录不存在,自动创建文件夹
File dir = new File(uploadDir);
if (!dir.exists()) {
dir.mkdir();
}
//遍历文件数组执行上传
for (int i = 0; i < file.length; i++) {
if (file[i] != null) {
//调用上传方法
executeUpload(uploadDir, file[i]);
}
}
} catch (Exception e) {
return "上传失败,请上传正确的视频并且上传大小在50MB之内!";
}
ret