Dropzone.js : 事件触发时停止添加到队列
Dropzone.js : stop adding to queue when event triggered
我正在使用 Dropzone.js 并希望在触发特定事件(达到最大文件数)时停止将文件添加到队列中。
假设我在 'Browse' window 中选择了 15 个文件,但我的 maxFiles 限制是 10。在第 11 个,触发了 maxfilesreached 事件。那时我希望剩下的 5 个文件不要添加到队列中。
这是我目前拥有的:
init : function() {
this.on('maxfilesreached', function(e){
alert("I want to stop adding stuff to the queue here");
});
当已经选择了太多文件时,我想取消所有未来添加到队列中的文件。我该如何继续?
提前致谢
A.
试试这个,
var myDropzone = new Dropzone("#dropzone", {
acceptedFiles: ".jpeg,.jpg,.png,.gif,.TIF,.JPEG,.JPG,.PNG,.GIF",
addRemoveLinks: true,
parallelUploads: 2,
thumbnailWidth: "80",
thumbnailHeight: "80",
dictCancelUpload: "Cancel",
autoProcessQueue: false
});
其中 #dropzone
是您的 dropzone id,无论它是表单 id 还是 div id。 parallelUploads: 5,
是设置上传最大文件数
我早该知道的。 RTFM。我和我的家人感到羞耻。
来自 FAQ,这是正确的方法:
this.on('maxfilesexceeded',function(file) {
this.removeFile(file);
alert("Oh wait you've exceeded your quota.");
});
我现在就去戴上耻辱锥。
我正在使用 Dropzone.js 并希望在触发特定事件(达到最大文件数)时停止将文件添加到队列中。
假设我在 'Browse' window 中选择了 15 个文件,但我的 maxFiles 限制是 10。在第 11 个,触发了 maxfilesreached 事件。那时我希望剩下的 5 个文件不要添加到队列中。
这是我目前拥有的:
init : function() {
this.on('maxfilesreached', function(e){
alert("I want to stop adding stuff to the queue here");
});
当已经选择了太多文件时,我想取消所有未来添加到队列中的文件。我该如何继续?
提前致谢
A.
试试这个,
var myDropzone = new Dropzone("#dropzone", {
acceptedFiles: ".jpeg,.jpg,.png,.gif,.TIF,.JPEG,.JPG,.PNG,.GIF",
addRemoveLinks: true,
parallelUploads: 2,
thumbnailWidth: "80",
thumbnailHeight: "80",
dictCancelUpload: "Cancel",
autoProcessQueue: false
});
其中 #dropzone
是您的 dropzone id,无论它是表单 id 还是 div id。 parallelUploads: 5,
是设置上传最大文件数
我早该知道的。 RTFM。我和我的家人感到羞耻。
来自 FAQ,这是正确的方法:
this.on('maxfilesexceeded',function(file) {
this.removeFile(file);
alert("Oh wait you've exceeded your quota.");
});
我现在就去戴上耻辱锥。