The description:
I am using the jquery.form.js
plugin to upload file to the server. I am using this plugin.
However, I am unable to set any filesize restriction and filetype restriction. I have PHP script enabled, but that works when file is started uploading to the server(it's a server side scription). I want a restriction in the client side so that it will disable the form submit button when the filesize and filetype doesn't match.
The jquery code:
$('#validatefrm').submit(function(e) {
$("#desc").val($('.Editor-editor').html());
if($('#image').val())
{
e.preventDefault();
$('#loader-icon').show();
$(this).ajaxSubmit({
target: '#targetLayer',
dataType: 'json',
beforeSubmit: function() {
$("#progress-bar").width('0%');
},
uploadProgress: function (event, position, total, percentComplete){
$("#progress-bar").width(percentComplete + '%');
$("#progress-bar").html('<div id="progress-status">' + percentComplete +' %</div>')
},
success:function (data){
var htmlMSG = '<b><span ';
if(data.type == 1)
{
htmlMSG += 'class="success-span"';
}
else
{
htmlMSG += 'class="fail-span"';
}
htmlMSG += ' >'+data.msg+'</span></b>';
$('.message-section').html('');
$('.message-section').append(htmlMSG);
$('#loader-icon').hide();
$('#myModal').modal('show');
/*var delay = 3000; //Your delay in milliseconds
var redirect = '<?php echo base_url();?>admin/post/edit_post/'+data.post_id;
setTimeout(function(){ window.location = redirect; }, delay);*/
},
resetForm: false
});
return false;
}
});