if you want to check file size using jQuery in php or set less-then or grater-then file size when you upload file in php. I will show you before upload file check file size using jQuery.
Form:
<form>
<div><input type=”file” name=”file” id=”file” class=”form-control” />
<p style=”color:red” id=”file_error”></span></div>
<div><input type=”submit” value=”Upload”/></div>
</form>
Script:
<script type=”text/javascript”>
function validate() {
$(“#file_error”).html(“”);
var file_size = $(‘#file’)[0].files[0].size;
if(file_size>5090152) {
$(“#file_error”).html(“File size is greater than 5MB, Please upload file less than 5MB”);
return false;
}
return true;
}
</script>
Question and answer is powered by AnsPress.io