Dropzone.js behaves unpredictably when using multipleUploads and parallelUploads

Viewed 15

I have a problem with Dropzone.js where it behaves unpredictably. I want to process multiple files at once, in this case, I drag 4 folders, each containing 10 files into the drop area.

What I expect, is, that dropzone only sends one request to the url, which indeed happens, but only sometimes. Other times it would split up the files into multiple chunks and send 2-3 requests. Is there anything that I'm missing.

php.ini is configured to allow max_file_uploads = 1000

What am I missing here?

index.html

<script src="https://unpkg.com/dropzone@6.0.0-beta.1/dist/dropzone-min.js"></script>
    <link href="https://unpkg.com/dropzone@6.0.0-beta.1/dist/dropzone.css" rel="stylesheet" type="text/css" />
<div id="dropTarget" class="dropzone"></div>
let myDropzone = new Dropzone("div#dropTarget", {
                url: "process.php",
                uploadMultiple: true,
                createImageThumbnails: false,
                paramName: "files",
                parallelUploads: 1000
            });

process.php

   echo count($_FILES['files']['name']);

Expected result

  • Drag 4 folders (each containing 10 files) into the drop area
  • One request, with all 40 files, should be sent to process.php

Actual result

  • Drag 4 folders (each containing 10 files) into the drop area
  • 2-3 requests are sent to process.php, each of them sending a chunk of files (i.e, 10, 10, 20)
  • Sometimes it happens that one request is sent with all 40 files.
1 Answers

Solution

Adding a timeout solved the issue for me

let myDropzone = new Dropzone("div#dropTarget", {
                url: "process.php",
                uploadMultiple: true,
                createImageThumbnails: false,
                autoProcessQueue: false,
                paramName: "files",
                parallelUploads: 1000,
            });



            myDropzone.on("addedfiles", function(file) {
                // Hookup the start button
                setTimeout(() => {
                    myDropzone.options.autoProcessQueue = true;
                    myDropzone.processQueue();
                }, 100);

            });

            myDropzone.on("queuecomplete", () => {
                myDropzone.options.autoProcessQueue = false;

            });
Related