dropzone js onclick submit file upload

前端 未结 5 1585
时光说笑
时光说笑 2020-12-24 02:11

upload all files with a single button click.
HTML:

5条回答
  •  旧时难觅i
    2020-12-24 02:35

    Although this has been answered, I ran into a situation where I only wanted to submit the queue IF it was a certain type of file. The bug I ran into was it was ignoring processQueue.

      this.dropzone = new Dropzone('#my-dropzone', {
        autoProcessQueue: false,
      });
      return this.dropzone.on('addedfile', (function(_this) {
        return function(file) {
    
          var IMAGE_EXTENSIONS, ext;
          IMAGE_EXTENSIONS = 'png jpg jpeg gif'.split(' ');
          ext = (_.last(file.name.split('.'))).toLowerCase();
    
          if (_.include(IMAGE_EXTENSIONS, ext)) {
            return console.log('IMAGE!');
          } else {
    
            return setTimeout(function() { // HERE!!!!!!!!!!!!!!!!!!!!
              return _this.dropzone.processQueue();
            }, 10);
          }
        };
      })(this));
    

    I had to use the setTimeout seen above because processQueue did nothing if I didn't defer it in this manner.

提交回复
热议问题