我在blueimp jQuery-File-Upload
中使用了验证功能,但在删除问题的文件时仍然无法提交文件。
如何在删除有问题的文件/文件后知道是否没有验证错误?
的Javascript
var isError = false;
var uploader = $('#fileUpload');
uploader.fileupload({
url: ' folder/class/method',
dataType: 'json',
sequentialUploads: false,
autoUpload: false,
maxFileSize: 1048576 * 10,
disableImageResize: /Android(?!.*Chrome)|Opera/
.test(window.navigator.userAgent),
previewMaxWidth: 70,
previewMaxHeight: 50,
previewCrop: true,
acceptFileTypes: /(gif|jpe?g|png|zip|7z)$/i,
maxNumberOfFiles: 3
});
// When add file
uploader.on('fileuploadadd', function (e, data) {
var d = data;
var fileContainer = $('<div/>').addClass('file');
$.each(data.files, function (index, file) {
$('<div/>').addClass('preview')/*.append($('<span/>').addClass('icon-file-empty fontSize_30'))*/.appendTo(fileContainer);
$('<div/>').addClass('name').html(data.files[0].name.substr(0, 25)).appendTo(fileContainer);
$('<div/>').addClass('size').html(filesize(data.files[0].size)).appendTo(fileContainer);
$('<div/>').addClass('file_progress_container').append($('<span/>').addClass('progress')).appendTo(fileContainer);
$("<button/>").addClass('delete_btn').append($('<span/>').addClass('icon-bin')).appendTo(fileContainer).on('click', function (e, data) {
$(this).parent().slideUp('fast', function () {
d.context.remove();
});
});
});
data.context = $(fileContainer).appendTo($('#showFiles_container fieldset'));
$('#beginUpload').on('click', function () {
if (isError == false && data.context.is(":visible")) {
data.submit();
}
});
});
uploader.bind('fileuploadprocessfail', function (e, data) {
data.context.css('opacity', '0.3').append($('<span/>').append(data.files[data.index].error));
if (data.files.error && data.files[data.index].error) {
isError = true;
} else {
isError = false;
}
});