how to validate file type, file size in jquery file upload ? i am using the following code .
$('#fileupload').fileupload({
dataType: 'json',
url: '/VendorReport/UploadFiles',
add: function (e, data) {
data.context = $('<button/>').text('Upload')
.appendTo($('#divUpload'))
.click(function () {
var ddlType = $("#ddlType").val();
if (ddlType == '') {
$('#divUpload').empty();
ShowNotify('Please select Type...!', 'warning', 2000);
return false;
}
$('#smp').empty();
data.context = $('<p/>').text('Uploading...').replaceAll($(this));
data.submit();
});
},
success: function (msg) {
UploadCall(msg.name);
},
done: function (e, data) {
data.context.text('');
}
});
please help me how to validate file size and file type.
You could use the validation options "acceptFileTypes" and "maxFileSize" as seen on the plugin wiki here.
Anyway an example:
$('#fileupload').fileupload({
acceptFileTypes: /(\.|\/)(mp4)$/i, //MP4
maxFileSize: 10000000 //10 MB
});