Uploading as folder structure

Home > Basic examples > Example 13

Explanation

Upload the file including the folder structure.

In the server, you can get the folder path with the name 'DEXTUploadX5_Folder'.

# Server-side					

// Get a file collection object.
List<MultipartFile> items = x5.getDEXTUploadX5_FileData();
// Get a collection object with a folder path. items.size() == folders.size()
List<String> folders = x5.getDEXTUploadX5_Folder();

for (int i = 0, len = items.size(); i < len; i++) {
	file = items.get(i);				
	if (file.isEmpty()) continue;

	sub = folders.get(i);			
	// Get path to be saved including directory(folder) information.
	dir = new File(file.getEnvironment().getDefaultRepository(), sub);
	// Create the folder structure.
	if (dir.exists() == false) dir.mkdirs();			
	// Save the file to the destination folder.
	file.save(dir.getCanonicalPath());
}

The folder structure upload precautions are as follows.

Example