-1

Using the jQuery wrapper technique for this question.

Using the autoUpload functionality I need to find out how many total files are going to be uploaded so this count can be used to determine when they're all complete (total files == uploaded files).

There are 2 requests here:

  1. With the autoUpload happening, how would I determine how many files are going to be uploaded, and when they have actually begun? This info will be used to both determine the total count, and to also disable buttons when it starts so the user must finish the uploads before moving on. Unless there's a better way?

  2. How do I know when the 'n' files have all completed so that my buttons can be enabled again? I do have the .on('complete') wired up already, so I think for this part I'm good to go. When the total files = uploadloaded files I think that I could enable the buttons again, etc.

Thanks!

Ray Nicholus
  • 19,538
  • 14
  • 59
  • 82
RichieMN
  • 905
  • 1
  • 12
  • 33

1 Answers1

0

I'm using FineUploader v3.8 UI with the jquery wrapper. Here's the solution that works for me regarding doing something (disabling buttons) while files are uploading.

What you see below are 2 chained handlers, the 'submitted' and 'complete' handlers. The 'submitted' handler counts the uploads using (previously declared) fileToUpload variable. The jQuery that's listed here then disables the buttons based on their type (button, submit, reset).

The 'complete' handler counts files that are completed using the (previously declared) uploadedFileCounter variable. If the uploadedFileCounter equals the fileToUpload then I know that all queued files are complete, and the buttons can be activated again (the .removeAttr).

 .on('submitted', function(event, id, filename) {
            filesToUpload++;
            $(':input[type=button], :input[type=submit], :input[type=reset]').attr('disabled', 'disabled');                
         }).on('complete', function(event, id, fileName, responseJSON) {                            
            uploadedFileCounter++;          

            if (filesToUpload == uploadedFileCounter)
            {
               uploadedFileCounter = 0;   
               $(':input[type=button], :input[type=submit], :input[type=reset]').removeAttr('disabled');                                                                
            }                            
 })            

Hope this helps!

RichieMN
  • 905
  • 1
  • 12
  • 33