0

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'
        }
    }
}
amphetamachine
  • 27,620
  • 12
  • 60
  • 72
Dablu Ansari
  • 7
  • 1
  • 4

1 Answers1

0

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

Community
  • 1
  • 1
LaVomit
  • 492
  • 5
  • 15