fine uploader - FineUploader uploads the same file multiple times at the same time -


say want upload several files @ once, can when setting multiple option true:

var myuploader = new qq.fineuploader({     element: $('#test')[0],     multiple: true,     request: { endpoint: 'path/to/master/server/php/' },     autoupload: false, }); 

now, let's have button allow me select files want upload. if click said button , select, say, test.txt file, test.txt added list of files uploaded. far good. now, problem that, if click button again, , select test.txt file again, added list though it's in list.

is there way prevent fineuploader letting me this?

thanks in advance

i'd careful declaring file duplicate based on name. should take size account, @ least. although, not possible in ie9 , older since can't determine file size client-side in browsers. purposes of simplicity, let's use file name exclusively...

one way maintain array of file names submitted uploader. can add list in onsubmitted handler. the, can contribute onvalidate handler reject file if exists in array. code this:

var filenames = []; var myuploader = new qq.fineuploader({     element: $('#test')[0],     multiple: true,     request: { endpoint: 'path/to/master/server/php/' },     autoupload: false,     callbacks: {         onsubmitted: function(id, name) {             filenames.push(name);         },         onvalidate: function(filedata) {             return qq.indexof(filenames, filedata.name) < 0;         }     } }); 

also, kicks, why not use fine uploader's jquery plug-in, since seems using jquery in project? above example rewritten using jquery plug-in below:

var filenames = []; $('#test').fineuploader({     multiple: true,     request: { endpoint: 'path/to/master/server/php/' },     autoupload: false })     .on("submitted", function(event, id, name) {         filenames.push(name);         })     .on("validate", function(event, filedata) {         return $.inarray(filedata.name, filenames) < 0;     }); 

Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

qt - Errors in generated MOC files for QT5 from cmake -