我有带输入的表格,并按dropzone上传图像 我的表格是ajax请求..一切正常 现在,当我提交表单时,我会返回错误消息(如果有错误消息),并且我无法再次提交表单
这是我的代码
Dropzone.options.myDropzone= {
url: "{{route('products::store')}}",
// autoProcessQueue: false,
uploadMultiple: true,
parallelUploads: 100,
maxFiles: 20,
maxFilesize: 0.7,
acceptedFiles: 'image/*',
addRemoveLinks: true,
dictRemoveFile: delete_image,
dictFileTooBig: larg_image,
init: function() {
dzClosure = this; // Makes sure that 'this' is understood inside the functions below.
document.getElementById("submit-all").addEventListener("click",function(e) {
// Make sure that the form isn't actually being sent.
// dzClosure.getQueuedFiles().length
if (dzClosure.files.length > 0) {
console.log(dzClosure.files);
e.preventDefault();
e.stopPropagation();
dzClosure.processQueue();
}else{
$("#submit-all").submit();
}
});
this.on("thumbnail", function(file) {
if (file.width > maxImageWidth || file.height > maxImageHeight) {
file.rejectDimensions()
}
else{
file.acceptDimensions();
}
});
this.on('sending', function(file, xhr, formData) {
var data = $('form').serializeArray();
$.each(data, function(key, el) {
formData.append(el.name,el.value);
});
});
},
accept: function(file, done) {
file.acceptDimensions = done;
file.rejectDimensions = function() { done(the_image_dimensions_are_large); };
},
}
任何解决方案?