我正在使用jquery文件上傳如下。使用jquery文件上傳驗證文件?
dialogElem.find('#upload-image-file-input').fileupload({
url: url,
dataType: 'json',
autoUpload: true,
acceptFileTypes: /(\.|\/)(gif|jpe?g|png)$/i,
maxFileSize: 5000000, // 5 MB
// Enable image resizing, except for Android and Opera,
// which actually support image resizing, but fail to
// send Blob objects via XHR requests:
disableImageResize: /Android(?!.*Chrome)|Opera/
.test(window.navigator.userAgent),
previewMaxWidth: 100,
previewMaxHeight: 100,
previewCrop: true
}).on('fileuploadadd', function (e, data) {
var fileCount = data.originalFiles.length;
if (fileCount > 5) {
alert("The max number of files is : "+5);
return false;
}
}).on('fileuploadprocessalways', function (e, data) {
//some logic
}).on('fileuploadprogress', function (e, data) {
//some logic
}).on('fileuploaddone', function (e, data) {
//some logic
}).on('fileuploadfail', function (e, data) {
//some logic
})
Inside fileuploadadd
我添加了一些驗證邏輯。如果驗證失敗,我如何停止所有其他事件,如fileuploadprogress
,fileuploadfail
和fileuploadprocessalways
?
難道ü嘗試?有用?我有一個不同的圖片上傳,不確定。 – Legendary 2015-03-13 12:36:19
我會盡力讓你知道..謝謝你的回答。 – user755806 2015-03-13 12:37:16