spring boot 上传文件

spring.servlet.multipart.max-file-size=23KB
spring.servlet.multipart.maxRequestSize=23KB
<form action="fileupload" method="post" enctype="multipart/form-data">
<input type="file" name="filename"/>
<input type="submit" />
</form>
@RestController
public class FileUploadController { @RequestMapping("/fileupload")
public Map<String,Object> fileUpload(MultipartFile filename) throws Exception {
System.out.println(filename.getOriginalFilename());
System.out.println(filename.getName());
System.out.println(filename.getSize());
Map<String,Object> map = new HashMap<>() ;
filename.transferTo(new File("d:/aaa"));
map.put("msg","ok");
return map;
}
上一篇:java 日志体系(三)log4j从入门到详解


下一篇:Articles Every Programmer Must Read