0

I'm using jQueryFileUpload to manage images in a folder. I'm trying to get the count of actual uploaded files. Actual means that I would like to increment a variable each time a new (single/multiple) upload is successfully performed and decrement it when files are deleted.

From official documentation, I've found these callbacks. I've successfully attached a callback to file uploader:

$('#fileupload').bind('fileuploadalways', function (e, data) 
{
    console.log(data);
});

Unfortunately, this solution has the following problems:

  • I'm not able to get the number of actual uploaded files in multiple uploads
  • callback is invoked on uploads only (not on delete)

Is there a way to keep the count of uploaded files after each upload/delete?

1 Answer 1

1

You can get a count for successfully uploaded files like below:

var filesuploadedSuccess =0;     
$('#fileupload').bind('fileuploaddone', function (e, data) {
  filesuploaded ++;
 });

Similarly you can use fileuploadfailed event to get failed upload count.

Use fileuploaddestroyed event to get the count for deleted files.

 $('#fileupload') .bind('fileuploaddestroyed', function (e, data) 
Sign up to request clarification or add additional context in comments.

4 Comments

Thanks for the answer, but unfortunately it still remains the problem of keeping track of deleted files (which is the biggest problem for me).
Either there can be a success or fail condition after each upload. When are you getting file deleted?
After successful uploads, a list of uploaded files is presented to you. Here you can decide to delete one or multiple files. And my goal is to keep track both of successful uploads and successful deletions.
You can use fileuploaddestroyed event to get the count for deleted files. $('#fileupload') .bind('fileuploaddestroyed', function (e, data)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.