Get upload file count

coder picture coder · Apr 7, 2012 · Viewed 8.1k times · Source

I am using jquery uploader from here and I would like to know how do I get the total number of files has been added and not uploaded.

There is no specific documentation on the new version so can anyone say me how do I do this?

As I need to get this way "uploading 1 of n files"

Here in the documentation says:

$('#fileupload').bind('fileuploadadded', function (e, data) {
  //Here I need to get the upload count.
 });

And If I as shown below it gives me count as 1

var totalfiles = data.files.length; 
alert(totalfiles);

Answer

lgomezma picture lgomezma · Apr 7, 2012

Following the documentation there's an event called 'fileuploadadd' that will fire every time a file has been added to the queue, so you could create a counter and increment it when the event is called.

var filestoupload =0;     
$('#fileupload').bind('fileuploadadd', function (e, data) {
      filestoupload++;
     });