$('.a').change(function(e) {
var _URL = window.URL || window.webkitURL;
var file, img;
if ((file = this.files[0])) {
img = new Image();
img.onload = function() {
$('.img').attr('src', this.src);
console.log(this.width)
};
img.src = _URL.createObjectURL(file);
}
})
使用
<img class="img" src="" width="100" height="100">
<input class="a" type="file">
标签:src,img,URL,JS,获取,window,file,var,图片 From: https://blog.51cto.com/jing/6002537