javascript - Limit the number of files that can be selected before uploading when using Plupload -
javascript - Limit the number of files that can be selected before uploading when using Plupload -
i'm using plupload upload files website. i'm trying limit number of files can selected before uploading. tried setting multi_selection
false
partially works. however, if click on 'select files' , take file via file explorer, wait file explorer close, click on 'select files' , same again, able select multiple files.
how can allow 1 file selected before uploading?
here demo of code i'm using: http://jsfiddle.net/5j8c05j9/
based on answers in question: jquery plupload restrict number of uploads.
you can add together next property plupload:
max_files: 1,
and alter filesadded
function, such:
filesadded: function(up, files) { plupload.each(files, function(file) { // if there more files allowed if (up.files.length > up.settings.max_files) { // display alert message alert('cannot send more ' + up.settings.max_files + ' file(s).'); // here can hide "select files" button next code //$(up.settings.browse_button).hide(); // cancel adding files. break each. homecoming false; } document.getelementbyid('filelist').innerhtml += '<div id="' + file.id + '">' + file.name + ' (' + plupload.formatsize(file.size) + ') <b></b></div>'; }); },
take @ updated jsfiddle
javascript jquery plupload
Comments
Post a Comment