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<FileItem> items = dextnj.getFileItems();			
// Get a collection object with a folder path. items.size() == folders.size()
List<FormItem> folders = dextnj.getFormItems("DEXTUploadX5_Folder");			

FileItem file = null;
FormItem form = null;
File dir = null;

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

	form = folders.get(i);
	// Get the path with folder.
	dir = new File(env.getDefaultRepository(), form.getValue());
	// 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