簡體   English   中英

如何在引導程序中驗證高度和寬度

[英]How to do validation of hight and width in bootstrap

如何在Bootstrap中驗證高度和寬度? 任何身體請幫助我...

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'
        }
    }
}

這個問題已經在這里回答 使用HTML5,可以檢查所選圖像文件的高度和寬度。

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);

    }

});

這是該頁面上的小提琴以對其進行測試: 演示

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM