4

I'm using dropzonejs this way:

<script type="text/javascript"> jQuery(function($) { try { $(".dropzone").dropzone({ paramName: "file", // The name that will be used to transfer the file maxFilesize: 0.5, // MB uploadMultiple: true, //addRemoveLinks : true, dictDefaultMessage : '<span class="bigger-150 bolder"><i class="icon-caret-right red"></i> Drop files</span> to upload \ <span class="smaller-80 grey">(or click)</span> <br /> \ <i class="upload-icon icon-cloud-upload blue icon-3x"></i>', dictResponseError: 'Error while uploading file!', //change the previewTemplate to use Bootstrap progress bars previewTemplate: "<div class=\"dz-preview dz-file-preview\">\n <div class=\"dz-details\">\n <div class=\"dz-filename\"><span data-dz-name></span></div>\n <div class=\"dz-size\" data-dz-size></div>\n <img data-dz-thumbnail />\n </div>\n <div class=\"progress progress-small progress-striped active\"><div class=\"progress-bar progress-bar-success\" data-dz-uploadprogress></div></div>\n <div class=\"dz-success-mark\"><span></span></div>\n <div class=\"dz-error-mark\"><span></span></div>\n <div class=\"dz-error-message\"><span data-dz-errormessage></span></div>\n</div>" }); } catch(e) { alert('Dropzone.js does not support older browsers!'); } }); </script> 

where exactly can I put a listener do do something (reload/redirect/alert) after ALL files are uploaded?

2 Answers 2

8

Here is a generic initialisation script using jQuery for Dropzone

Dropzone.options.myDropZoneForm = { url: 'url/here', autoProcessQueue: false, uploadMultiple: true, parallelUploads: 100, addRemoveLinks: true, uploadMultiple: true, acceptedFiles: 'image/*, audio/*, video/*', maxFiles: 10, init: function () { var thisDropzone = this; // just showing some dropped files stats var totalFiles = 0, completeFiles = 0; this.on('addedfile', function(file){ totalFiles += 1; totalFilesFormatted = totalFiles.toFixed(2); $('#showTotalFileCount').html(totalFilesFormatted); }); this.on('removedfile', function(file){ totalFiles -= 1; totalFilesFormatted = totalFiles.toFixed(2); $('#showTotalFileCount').html(totalFilesFormatted); }); this.on('maxfilesreached', function(file){ alert('maxFiles reached'); }); this.on('maxfilesexceeded', function(file){ alert('files dropped exceeded maxFiles'); }); this.on("sendingmultiple", function(){ // event when files are being sent }); this.on("successmultiple", function(files, response) { // event when files are successfully uploaded // you can return a response string and process it here through 'response' }); this.on("errormultiple", function(files, response) { // event when there's an error }); } } 

Hope this helps you iron out things. Cheers!

Sign up to request clarification or add additional context in comments.

Comments

1

You need the parameter completemultiple which is a function that will be called once all files have been uploaded.

Also fo interest to you:

  • processingmultiple
  • sendingmultiple
  • successmultiple
  • canceledmultiple

From: http://www.dropzonejs.com/

2 Comments

can you please give me an example? I tried this way but it doesn't work: init: function() { this.on("completemultiple", function(file) { alert("Added file."); }); },
So you don't see the alert? Can you check to make sure you have the latest dropzone JS? Add the completemultiple parameter along the other dropzone parameters like paramName.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.