@PostMapping ( "/upload" ) public String upload ( @RequestParam ( "email" ) String email, @RequestParam ( "username" ) String username, @RequestPart ( "headerImg" ) MultipartFile headerImg, @RequestPart ( "photos" ) MultipartFile [ ] photos) throws IOException { log. info ( "上传的信息:email={},username={},headerImg={},photos={}" , email, username, headerImg. getSize ( ) , photos. length) ; if ( ! headerImg. isEmpty ( ) ) { String originalFilename = headerImg. getOriginalFilename ( ) ; headerImg. transferTo ( new File ( "H:\\cache\\" + originalFilename) ) ; } if ( photos. length > 0 ) { for ( MultipartFile photo : photos) { if ( ! photo. isEmpty ( ) ) { String originalFilename = photo. getOriginalFilename ( ) ; photo. transferTo ( new File ( "H:\\cache\\" + originalFilename) ) ; } } } return "main" ; }
spring. servlet. multipart. max- file- size= 10 MB
spring. servlet. multipart. max- request- size= 100 MB