input file上传图片显示图片
<img class="img" src="" width="100" height="100"> <input class="a" type="file">
$('.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);
}
})本文由:xiaoshu168 作者:xiaoshu发表,转载请注明来源!