This post walks you through the process of creating the Uploading Multiple Files Example with Spring Boot.

Hello Spring Boot Series:
- Spring Boot Hello World Example with FreeMarker
- Spring Boot Hello World Example with Thymeleaf
- Spring Boot Hello World Example with JSP

What you'll build

What you'll need

  • JDK 1.7 or later
  • Maven 3 or later

Stack

  • Java
  • Spring Boot
  • Freemarker

Project structure

├── src
│   └── main
│       ├── java
│       │   └── com
│       │       └── hellokoding
│       │           └── uploadingfiles
│       │               ├── Application.java
│       │               └── UploadingController.java
│       ├── resources
│       │   └── application.properties
│       └── webapp
│           └── uploading.ftl
└── pom.xml

Project dependencies


Uploading Controller


View Template


<form name="uploadingForm" enctype="multipart/form-data" action="/" method="POST">  

action="/" and method="POST" map with uploadingPost() of UploadingController, enctype="multipart/form-data" works with MultipartFile.

Application Configuration



new File(UploadingController.uploadingdir).mkdirs(); makes a directory for uploading files if not exists.

Run

mvn spring-boot:run

Source code

[email protected]:hellokoding/uploadingfiles-springboot.git https://github.com/hellokoding/uploadingfiles-springboot

Using files from web applications
Getting Started Uploading Files