注: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"; } }
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)