2017-02-22 55 views
0

Когда я начинаю загружать несколько файлов, используя следующий код, addRemoveLinks: истинная дает возможность отменить загрузку. Когда я отменяю любой из загружаемых файлов, он перестает загружать все файлы. Он также показывает общий процент прогресса на 100% после этого.Отмена загрузки для одного файла останавливает загрузку всех файлов - Dropzonejs

Может кто-нибудь, пожалуйста, помогите мне понять, что я делаю неправильно? Я хочу, чтобы при отмене загрузки для одного файла не влияло на загрузку других файлов. Как я могу это сделать?

Dropzone.options.myAwesomeDropzone = { 

    autoProcessQueue: false, 
    uploadMultiple: true, 
    parallelUploads: 100, 
    maxFiles: 100, 
    maxFilesize: 1000, 
    addRemoveLinks: true, 
    // The setting up of the dropzone 
    init: function() { 
     var myDropzone = this; 
     this.element.querySelector("button[type=submit]").addEventListener("click", function (e) { 
      // Make sure that the form isn't actually being sent. 
      e.preventDefault(); 
      e.stopPropagation(); 
      var atLeastOneIsChecked = $('input:checkbox').is(':checked'); 
      if(atLeastOneIsChecked) 
       myDropzone.processQueue(); 
      else 
       alert("Please select a company!"); 
     }); 

     myDropzone.on("totaluploadprogress", function (progress) { 
      // Update progress bar with the value in the variable "progress", which 
      // is the % total upload progress from 0 to 100 
      $("#prog").html(progress); 
     }); 

     myDropzone.on("drop", function (event) { 
      // Update progress bar with the value in the variable "progress", which 
      // is the % total upload progress from 0 to 100 
      $("#prog").html("0"); 
     }); 

    } 

} 

ответ

0

Я решил эту проблему, изменив исходный код.

Dropzone.prototype.cancelUpload = function (file) { 
    var groupedFile, groupedFiles, _i, _j, _len, _len1, _ref; 
    if (file.status === Dropzone.UPLOADING) { 
     this.emit("canceled", file); 
    } else if ((_ref = file.status) === Dropzone.ADDED || _ref === Dropzone.QUEUED) { 
     file.status = Dropzone.CANCELED; 
     this.emit("canceled", file); 
     if (this.options.uploadMultiple) { 
      this.emit("canceledmultiple", [file]); 
     } 
    } 
    if (this.options.autoProcessQueue) { 
     return this.processQueue(); 
    } 
}; 

 Смежные вопросы

  • Нет связанных вопросов^_^