提交表单时,如果任何表单字段(例如标题)中存在错误,则必须由用户重新上载文件。
I am trying to implement this code into my script to fix this issue but it is not working
Dropzone.prototype.requeueFiles = function(files){
for (var i = 0, l = files.length, file; i < l; i++){
file = files[i];
file.status = Dropzone.ADDED;
file.upload.progress = 0;
file.upload.bytesSent = 0;
}
}
//...on submit
self.requeueFiles(self.files);
注意评论:
I think you may set the status to Dropzone.QUEUED
这是我目前的代码:
$(document).ready(function() {
var dropzone;
Dropzone.autoDiscover = false;
dropzone = new Dropzone('#dropform', {
maxFiles: 2,
maxFilesize: 2.5,
paramName: 'photo[picture]',
headers: {
"X-CSRF-Token": $('meta[name="csrf-token"]').attr('content')
},
addRemoveLinks: true,
clickable: '.dz-default.dz-message',
previewsContainer: '.dz-default.dz-message',
thumbnailWidth: 200,
thumbnailHeight: 200,
parallelUploads: 100,
autoProcessQueue: false,
uploadMultiple: false
});
$('#item-submit').click(function(e) {
e.preventDefault();
e.stopPropagation();
if (dropzone.getQueuedFiles().length > 0) {
return dropzone.processQueue();
}
else {
return $('#dropform').submit();
}
});
dropzone.on('error', function(file, errorMessage, xhr) {
console.log('error');
$('.idea').html(errorMessage + ". Please try again. Thank you.");
});
return dropzone.on('success', function(file, responseText) {
return window.location.href = '/photos/' + responseText.id;
});
});