<script src="http://libs.baidu.com/jquery/2.0.0/jquery.js"></script>
<input name="pic" id="pic" class="txt_form" type="file"><span id="pic_info" style="color:red;"></span>
<img src="" alt="" id="lod_pic" width="580" >
var file = this;
createReader(file.files[0], function (w, h, u) {
// alert(w + ' '+ h +' '+u);
$('#lod_pic').attr("src",u);
$('#pic_info').text("(圖片尺寸:"+w+"x"+h+")");
});
})
createReader = function(file, whenReady) {
var reader = new FileReader;
reader.onload = function (evt) {
var image = new Image();
image.onload = function () {
var pic_url = this.src;
var width = this.width;
var height = this.height;
if (whenReady) whenReady(width, height , pic_url);
};
image.src = evt.target.result;
};
reader.readAsDataURL(file);
}