jquery fileupload - data.files.length returns 1 -



jquery fileupload - data.files.length returns 1 -

i'm using jquery fileupload without ui.

i want command max files uploaded.

for i'm checking data.files.length in add together event , if select , upload 8 files 8 times 1 not 1 time 8

$('#fileupload').fileupload({ datatype: 'json', add: function(e, data) { console.log(data.files.length); //8 times 1 - not 8 } });

i can create this:

add: function(e, data) { files+=data.files.length; if (files>5) { jqxhr = data.submit(); jqxhr.abort(); } },

but 1 file manages upload :/

how limit number of uploaded files without using ui (and depencies video, image, sound , on)?

you'll need hear fileuploadadd event , utilize maintain track of number of files added. along lines of this:

var allowedfilescount = 8; var addedfilescount = 0; $('#fileupload').bind('fileuploadadd', function (e, data) { addedfilescount++; }); $('#fileupload').fileupload({ datatype: 'json', add: function(e, data) { if (addedfilescount <= allowedfilescount){ alert("allowed"); } else { alert("at max"); } } });

jquery file-upload jquery-file-upload

Comments

Popular posts from this blog

model view controller - MVC Rails Planning -

ruby on rails - Devise Logout Error in RoR -

html - Submenu setup with jquery and effect 'fold' -