Sunday, 21 May 2017

Restrict image size using J Query

Restrict image size very essay. we can find image upload using "change" Event. get value using "val" attribute.

The below code useful  to find Image size

J Query Code
-------------------------
$(function() {
$("#gal_image").change(function(e) {
if(this.files[0].size >= 1073741824){
alert("Image file size should be below 1 GB");
$('#gal_image').val('');
return false;
}

});
});

HTML Code
----------------------

<input type="file" id="gal_image" name="gal_image"  />

No comments:

Post a Comment