How to do validation of hight and width in bootstrap ? Any body plz help me...
company_logo: {
validators: {
file: {
extension: 'jpeg,png,jpg',
type: 'image/jpeg,image/png,image/jpg',
maxSize: 100024, // 2048 * 1024
message: 'The selected file is not valid'
}
}
}
This question has already been answered here . With the use of HTML5, you can check the height and width of the selected image file.
var _URL = window.URL || window.webkitURL;
$("#file").change(function(e) {
var image, file;
if ((file = this.files[0])) {
image = new Image();
image.onload = function() {
alert("The image width is " +this.width + " and image height is " + this.height);
};
image.src = _URL.createObjectURL(file);
}
});
Here's a fiddle from that page to test it: demo
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.