Last active
March 10, 2019 12:15
-
-
Save ezhov-da/5d076cd8e199effc06248d50c622686c to your computer and use it in GitHub Desktop.
загрузка файла
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Для примитивной загрузки файла необходимо определить форму: | |
<html> | |
<head> | |
</head> | |
<body> | |
<form enctype="multipart/form-data" action="http://localhost:8080/upload" method="POST" accept-charset="utf-8"> | |
<input type="file" name="file"> | |
<input type="submit" value="Upload File" /> | |
</form> | |
</body> | |
</html> | |
Backend: | |
Spring Boot: | |
Контроллер: | |
@RequestMapping(path = "/upload", method = RequestMethod.POST) | |
public String upload(@RequestParam("file") MultipartFile file) { | |
return file.getOriginalFilename(); | |
} | |
Настройка допустимого размера файлов в файле application.properties: | |
spring.servlet.multipart.max-file-size=128KB | |
spring.servlet.multipart.max-request-size=128KB | |
spring.http.multipart.enabled=false |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment