<script type="text/javascript">
function ValidateSize(file) {
var FileSize = file.files[0].size / 1024 / 1024; // in MB
if (FileSize > 2) {
alert('File size exceeds 2 MB');
$(file).val(''); //for clearing with Jquery
} else {
}
}
</script>
<input onchange="ValidateSize(this)" type="file" id="file">
Here is the code. I desire that if the image size is greater than 2 mb, the image should not append but clear from file. Any help please.