Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dropzone.js uploads only two files when autoProcessQueue set to false

I use Dropzone.js and I want it to upload the dropped not automatically but when the user clicks a button. So I set the autoProcessQueue option to false. When the button is clicked the processQueue() method is called. I would suppose that now the full queue is processed. But thats not the case. Only the number of files which is specified in the parallelUploads option will be uploaded. The standard value of parallelUploads seems to be 2. Which every click 2 files are processed and uploaded.

Do I have to set parallelUploads to an very high number, for now to solve this?

Here's my full JS code:

var myDropzone = new Dropzone("div#myId", {
  url: "http://www.torrentplease.com/dropzone.php",
  addRemoveLinks: true,
  thumbnailWidth: "80",
  thumbnailHeight: "80",
  dictCancelUpload: "Cancel",
  autoProcessQueue: false
});

myDropzone.on("drop", function(event) {
  $('.edit_tooltip .option_bar').animate({
    opacity: 1,
    top: "-5"
  });
});


$('.edit_tooltip .option_bar .button').click(function() {
  myDropzone.processQueue();
});
like image 329
Juuro Avatar asked Aug 05 '13 13:08

Juuro


5 Answers

Add parallelUploads: 10(This is your max no)

like image 106
Venom Avatar answered Nov 15 '22 08:11

Venom


There's a simple way to solve this which can be found here:

https://github.com/enyo/dropzone/issues/253#issuecomment-22184190

"If you want autoProcessQueue to be true after the first upload, then just listen to the processing event, and set this.options.autoProcessQueue = true; inside."

So just add

this.on("processing", function() {
    this.options.autoProcessQueue = true;
});
like image 34
Bianka M. Avatar answered Nov 15 '22 10:11

Bianka M.


My solution is:

// init dropzone with auto process queue false
var adPhotosDropzone = new Dropzone("#dropzone", {
    autoProcessQueue: false,
    parallelUploads: 3
});

$(document).on('click', '#btnUpload', function () {
    // enable auto process queue after uploading started
    adPhotosDropzone.options.autoProcessQueue = true;
    // queue processing
    adPhotosDropzone.processQueue();
});

// disable queue auto processing on upload complete
adPhotosDropzone.on("queuecomplete", function() {
    adPhotosDropzone.options.autoProcessQueue = false;
});
like image 22
Viktor Sanzharevskyy Avatar answered Nov 15 '22 08:11

Viktor Sanzharevskyy


Very late but maybe it will help someone.

I noticed when I placed maxFilesSize above parallerUploads it didn't worked.

So sequence for options should be .

.
.
parallelUploads: 20,    
maxFilesize: 2, 
maxFiles: 20,
.
.
like image 7
m.qayyum Avatar answered Nov 15 '22 09:11

m.qayyum


Add overdrive two event like

processing -> Allow upload all file

queuecomplete -> Return to normal

    init: function () {

            this.on("queuecomplete", function () {
                this.options.autoProcessQueue = false;
            });

            this.on("processing", function () {
                this.options.autoProcessQueue = true;
            });

    };
like image 4
Ahmad Aghazadeh Avatar answered Nov 15 '22 08:11

Ahmad Aghazadeh