使用 Dropzone.js,这是代码。 选项“maxFiles = 1”确实可以防止在浏览时选择多个文件,但不会停止将多个文件“拖”到拖放区。知道如何防止拖动多个文件吗?
$(".dropzone").dropzone({
dictDefaultMessage: "Drag image here",
uploadMultiple: false,
parallelUploads: 1,
clickable: true,
maxFiles: 1,
url: 'somewhere' // Provide URL
});
最佳答案
请添加以下代码,
init: function() {
this.on('addedfile', function(file) {
if (this.files.length > 1) {
this.removeFile(this.files[0]);
}
});
}
关于javascript - Dropzone.js - maxFiles = 1 不会停止拖动多个文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30437789/