注:enctype="multipart/form-data"
文件上传
控制层
@Controller
public class FileUploadController {
@ResponseBody
@PostMapping("/upload")
public String upload(@RequestPart("word")MultipartFile word,
@RequestPart("photos")MultipartFile[] photos) throws IOException {
if(!word.isEmpty()) {
String fileName = word.getOriginalFilename();
word.transferTo(new File("D:\" + fileName));
}
if(photos.length > 0) {
for (MultipartFile photo : photos) {
if(!photo.isEmpty()) {
String fileName = photo.getOriginalFilename();
photo.transferTo(new File("D:\" + fileName));
}
}
}
return "success";
}
}



