Skip to content

Instantly share code, notes, and snippets.

@ezhov-da
Last active March 10, 2019 12:15
Show Gist options
  • Save ezhov-da/5d076cd8e199effc06248d50c622686c to your computer and use it in GitHub Desktop.
Save ezhov-da/5d076cd8e199effc06248d50c622686c to your computer and use it in GitHub Desktop.
загрузка файла
Для примитивной загрузки файла необходимо определить форму:
<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