LPology / Simple-Ajax-Uploader

Javascript file upload plugin with progress bar support. Works in all major browsers, including IE7+, Chrome, Firefox, Safari, and Opera. No dependencies - use it with or without jQuery.
995 stars 267 forks source link

Upload multiple files using multipart: true #123

Closed Thilaga14 closed 8 years ago

Thilaga14 commented 8 years ago

how to upload multiple files using multipar:true.

anyexamples?

LPology commented 8 years ago

It's the same as the example in the README. What problem are you having?

LPology commented 8 years ago

None of the files are being sent to the server at all?

LPology commented 8 years ago

Can you explain exactly what is happening when you try to upload a file?

Also, set debug: true in your settings and let me know what it says your browser console.

Thilaga14 commented 8 years ago
  1. I can able to select multiple files(for ex : 3) in file browser and click open
  2. But in ajax call, I can see 14 params in Request payload in that 13 are data params and 1 is file (only one file is going instead of 3)

In console :

[Uploader] Commencing upload using multipart form [Uploader] Server response: {"Audit_ID" : "21"}

LPology commented 8 years ago

That is actually how the plugin works -- it only sends one file per request. The reason is to support multiple, concurrent file uploads in IE7-9. When multiple files are being uploaded, each file upload is a separate request.

Thilaga14 commented 8 years ago

It is not even sending multiple request. It is sending one request and one file. You can prevent using both multipart:true and multiple: true at the same time.

Thanks !

LPology commented 8 years ago

What browser are you using?

Thilaga14 commented 8 years ago

Chrome

LPology commented 8 years ago

I'm not sure what the issue could be. It doesn't seem like there should be any reason why you are only having one request when you select more than one file.

Is there a way you can post a link to a live example? If you can't do that, can you post or link to the full code?

LPology commented 8 years ago

Is the one file that is being sent successfully uploading?

Thilaga14 commented 8 years ago

yes. I can read and store

LPology commented 8 years ago

I think I've figured it out. I think it's because you have autoSubmit: false and when you submit the upload here:

self.state.myUploader.submit();

It's only submitting the first file because when autoSubmit is false, the plugin does not automatically submit the next file. You could do something like this:

if(self.state.isFileSelected)
       {                
         console.log(' an file upload');    
           self.state.myUploader.setOptions({
                data : data
            });
            var num = self.state.myUploader.getQueueSize();
             for ( var i = 0; i < num; i++ ) {
                  self.state.myUploader.submit();
              }

        }

This finds how many files were selected using getQueueSize() and then submits each file individually.

Can you try this and see if it works?

Thilaga14 commented 8 years ago

Yup! you solved it . Thanks :). I can see multiple request with one file at a time.

Last question for better understanding,

Chrome - select n files and send n requests, one file at time. IE7-9 - not able to select multiple files as browser is not supporting IE10+ - works like chrome.

is anything possible like one request with multiple files ?

correct me if i am wrong.

LPology commented 8 years ago

Glad I could help. You're correct about the browsers.

One request with multiple files might be possible. I'd have to work on it, but it could potentially be in a future release. I'll look into it.

Thilaga14 commented 8 years ago

Resolved..