Answer the question
In order to leave comments, you need to log in
Why Bad Request, status=400 when uploading files?
Whitelabel Error Page
This
application has no explicit mapping for /error, so you are seeing this as a fallback.
Tue Jan 25 13:54:17 YEKT 2022
There was an unexpected error (type=Bad Request, status=400).
Controller
@GetMapping("/uploadtest")
public String uploadtest(Model model) {
return "upload";
}
@PostMapping("/postupload")
public String postupload(@RequestParam("files") MultipartFile[] images,Model model) {
return "upload";
}
<form method="post" action="/postupload" enctype="multipart/form-data">
<input type="file" name="images" multiple class="form-control" accept=".jpg, .jpeg" >
<button type="submit" >Upload</button>
</form>
Answer the question
In order to leave comments, you need to log in
Good afternoon!
Your input is calledimages
<input type="file" name="images" multiple class="form-control" accept=".jpg, .jpeg" >
files
@RequestParam("files") MultipartFile[] images
@RequestParam("files") MultipartFile[] files
solved the problem
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question