【发布时间】:2016-08-25 11:51:06
【问题描述】:
我正在使用 dropzone 上传文件,我已将文件限制设置为最多六个文件,如果我一次上传一张图片,此代码有效,但如果我在开始时按控制按钮选择超过六个图片上传文件然后它不会验证文件并上传所有文件。我使用 laravel 作为后端,我的代码是:-
Dropzone.options.myAwesomeDropzone = {
paramName: "file", // The name that will be used to transfer the file
maxFilesize: 1, // MB
maxFiles: 6,
acceptedFiles: ".jpeg,.jpg,.png,.gif",
clickable: true,
init: function () {
this.on("success", function(file, responseText) {
file.previewTemplate.setAttribute('id',responseText[0].id);
});
this.on("thumbnail", function(file) {
if (file.width < 350 || file.height < 200) {
file.rejectDimensions()
}
else {
file.acceptDimensions();
}
});
},
accept: function(file, done) {
file.acceptDimensions = done;
file.rejectDimensions = function() { done("Image width or height should be greater than 350*200"); };
},
removedfile: function(file){
var name = file.name;
$.ajax({
type: 'POST',
url: ajax_url+'listing/deleteListingImage/'+name,
dataType: 'html'
});
var _ref;
return (_ref = file.previewElement) != null ? _ref.parentNode.removeChild(file.previewElement) : void 0;
},
dictDefaultMessage: "Drop your files to upload"
}
谢谢
【问题讨论】:
-
A.
console中的任何错误? B. 你读过docs about it 吗?不是验证,只是调用事件maxfilesexceeded。 -
它的验证很好,唯一的问题是如果我一次上传超过六张图片
-
在控制台也没有给出任何错误
标签: javascript jquery html dropzone.js