【发布时间】:2016-02-08 08:59:34
【问题描述】:
<input type="file" class="test" name="vend_logo" id="vend_logo">
$('.test').bind('change', function() {
var file = files[0]
var img = new Image();
var width = img.width;alert(width);
});
我想提醒上传的图片宽度和高度。我怎样才能做到这一点 ?我使用了clientwidth 和naturalwidth,但它没有显示正确的值。
【问题讨论】:
-
为什么要使用
img = new Image();创建新图像? -
不需要?
-
$('.test').bind('change', function() { var width = this.files[0].width; alert(width); });我已经改变了这样的代码。但它不工作..