感谢。
$('#File').change(function (evt) {
var f = evt.target.files[0];
var reader = new FileReader();
var H = f.height;
var W = f.width;
if (W > 100) {
alert("The selected file is too large.");
return;
}
if (!f.type.match('image.*')) {
alert("The selected file does not appear to be an image.");
return;
}
setBox('#IsFile');
reader.onload = function (e) { preview.attr('src', e.target.result); };
reader.readAsDataURL(f);
});
答案 0 :(得分:0)
解决方法是将图像加载到屏幕外的图像元素,然后使用类似于此的方法检测宽度/高度:
var img = document.getElementById('offscreenImageId');
//or however you get a handle to the IMG
var width = img.clientWidth;
var height = img.clientHeight;