Dropzone js - maxFiles无效

时间:2016-02-23 21:35:10

标签: javascript drag-and-drop dropzone.js

我正在使用 dropzone.js 构建拖放文件上传。第一次上载文件时,maxFiles配置选项很有效。但是,当我显示已上载的文件并尝试再次上传时,maxFiles配置将被忽略。

我显示已经上传的文件,如下所示:

init: function() {
    var thisDropzone = this;
    track = getParameterByName('trackno');
    $.getJSON('get_upload_files.php?track='+track, function(data) { // get the json response
      $.each(data, function(key,value){ //loop through it
        var mockFile = { name: value.name, size: value.size }; // here we get the file name and size as response 
        thisDropzone.options.thumbnail.call(thisDropzone, mockFile, "uploads/"+value.name);//uploadsfolder is the folder where you have all those uploaded files
        thisDropzone.emit("addedfile", mockFile);
      });
    });
   }

1 个答案:

答案 0 :(得分:1)

一旦知道已上传了多少文件,您可以做的是更新$.when值。

假设您最多需要10个文件,它们将如下所示:

option.maxFiles