Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

upload multiple files in one request Dropzone sending two requests

I am trying to send multiple files in one request using DropZone js.

Here's my code :

Dropzone.autoDiscover = false;

var myDropzone = new Dropzone('#upload-Invoices', {       
    paramName: "files", 
    maxFilesize: 3.0, 
    maxFiles: 4,
    parallelUploads: 10000,
    uploadMultiple: true,
    autoProcessQueue: false
});

$('#btnUpload').on('click', function () {
    myDropzone.processQueue();
});

Controller :

public void FileUpload( IEnumerable<HttpPostedFileBase> file )
{
    // Do Something
}

View:

<form action="/Index/FileUpload"
      class="dropzone"
      id="upload-Invoices" data-ajax-method="POST" data-ajax="true">
    <input type="submit" value="Upload File to Server" id="btnUpload">
</form>

The files are being received although in diferrent requests, I want to send all files in one request, the Dropzone page has an option for it although it does not work. Thanks in Advance

like image 352
SJMan Avatar asked Jan 19 '15 10:01

SJMan


People also ask

What is maxFilesize in Dropzone?

I'm using Dropzone. js for my website. I'm in the need of uploading bigger files than the default maxFilesize of 500MB.


3 Answers

you can use uploadMultiple property default value false change it to true

$(".dropzone").dropzone({
            // autoQueue:false,
            parallelUploads:10,
            uploadMultiple:true,

https://www.dropzonejs.com/#config-uploadMultiple

like image 51
ahmedkandil Avatar answered Sep 28 '22 04:09

ahmedkandil


The Issue was that I was using an input type="submit" which would do another post by itself, changing it to type button worked.

like image 44
SJMan Avatar answered Sep 28 '22 05:09

SJMan


Had the same problem, just add autoDiscover: false, to your dropzone options and it should work!

My options are like this:

Dropzone.options.UploadZone = {        
    addRemoveLinks: true,
    autoDiscover: false,
    uploadMultiple: true,
    parallelUploads: 10,
    maxFiles: 10,
    acceptedFiles: ".jpeg,.jpg,.png",
    autoProcessQueue: false,
    ...

With autoProcessQueue: false and uploadMultiple: true: for each 2 files i was getting a request.

Then I added parallelUploads: 10 and maxFiles: 10 and i don't know why but my first 2 files started uploading as soon as i putted them on the dropzone, even with autoProcessQueue: false.

Then I just add autoDiscover: false and everything worked fine from there!

good look!

like image 24
MarchalPT Avatar answered Sep 28 '22 05:09

MarchalPT