I don\'t see an option in the plupload API docs on restricting the number of files uploaded, to any number, even 1.
Doc fail? or Feature fail? If it doesn\'t exist I\'ll
If you want to use a custom uploader, and upload one file at a time, no auto upload and have the last file added become the new file use this.
uploader.bind('FilesAdded', function(up, files) {
// Clear the HTML
$('#plupload-files').html('');
// Plup does not offer before file added event
if (up.files.length > 1) {
up.splice(0, up.files.length);
up.addFile(files[0])
return;
}
// $.each(files, function(){....
}
We splice the whole array because plup already adds all the files to the queue and if you splice the queue like the accepted answer you will actually add one file everytime the user tries to add files, and if they try to add a new file singularly it will keep the old file at pos[0] in the files array,
Then we add the first file of the files that they tried to add. This way there is only ever one file in the queue and it is always the first file in the last group of files they tried to add.
ie.
Drag into plupload 'file1.jpg', 'file2.jpg', 'file3.jpg'
clear the whole queue, add back 'file1.jpg'
Drag into plupload 'file4.jpg', 'file5.jpg', 'file6.jpg'
clear the whole queue, add back 'file4.jpg'
Drag into plupload 'file99.jpg'
clear the whole queue, add back 'file99.jpg'
This allows you to manage custom plups if you only ever want to upload one file at a time. As stated the other answers only work once, or with auto start uploads.