Works with any backend npm install Zero dependencies

Directory Browse (webkitdirectory)

Enable the native folder picker dialog via the webkitdirectory option.

(function() {
 new MultipleUpload('#demo', {
 uploadUrl: '/api/upload',
 multiple: true,
 webkitdirectory: true,
 autoUpload: false,
 buttonText: 'Select Folder'
 });
})();

Picking a folder rather than files

webkitdirectory: true turns the browse button into a directory picker: the user chooses one folder and every file inside it, at every depth, enters the queue. The component also forces the input to accept multiple files when this is on, so you do not have to set multiple as well.

The path survives

Each file keeps its place in the tree. The browser exposes that as webkitRelativePath and the component surfaces it as the task's relativePath, so the folder can be reconstructed on the server instead of collapsing into a flat pile of files.

Relative paths come from the client, so they are input rather than fact. Sanitise before joining one to a directory on disk — a path is the classic way a traversal gets in.