Spring MVC supports file uploads through the MultipartFile abstraction, which represents an uploaded file as a bound method parameter once the underlying multipart request has been parsed by a multipart resolver.
A profile picture upload form posts to /uploadAvatar with an input named "file"; the controller method declares @RequestParam("file") MultipartFile file, checks its size and content type, and calls file.transferTo(destination) to save it to disk.
@PostMapping("/uploadAvatar")
public String upload(@RequestParam("file") MultipartFile file) throws IOException {
if (!file.isEmpty()) {
file.transferTo(new File("/uploads/" + file.getOriginalFilename()));
}
return "redirect:/profile";
}A concise interview answer is
Spring MVC represents an uploaded file as a MultipartFile bound via @RequestParam, as long as the form uses enctype multipart/form-data. From there I can read the file's bytes, name, and size, or call transferTo() to save it — Spring Boot wires up the multipart resolver automatically.
Last updated: 16 July 2026
Previous question: What are the best practices for integration testing in Spring MVC?
Next question: What configurations are needed to enable file uploads in a Spring MVC application?