dropzone.js - how to do something after ALL files are uploaded

后端 未结 9 1174
花落未央
花落未央 2020-12-13 05:48

I am using dropzone.js for my drag-drop file upload solution. I am stuck at something where I need to call a function after all the files are uploaded. In this case

9条回答
  •  爱一瞬间的悲伤
    2020-12-13 06:33

    EDIT: There is now a queuecomplete event that you can use for exactly that purpose.


    Previous answer:

    Paul B.'s answer works, but an easier way to do so, is by checking if there are still files in the queue or uploading whenever a file completes. This way you don't have to keep track of the files yourself:

    Dropzone.options.filedrop = {
      init: function () {
        this.on("complete", function (file) {
          if (this.getUploadingFiles().length === 0 && this.getQueuedFiles().length === 0) {
            doSomething();
          }
        });
      }
    };
    

提交回复
热议问题