close
function getImgSize(input) {
if (input.files && input.files[0]) {
var reader = new FileReader();
reader.onload = function (e) {
$('#testImg').attr('src', e.target.result);
}
reader.readAsDataURL(input.files[0]);
}
}
$('#testImg').on('load',function(){
alert($(this).width()+'*'+$(this).height());
})
$("input").change(function(){
getImgSize(this);
});
<input type="file"/>
<img id="testImg" src="#" alt="your image" />
-----http://jsfiddle.net/Mqvgx/----------------------------------------------------------------
<script type="text/javascript">
function showimages(files) {
for (var i = 0, f; f = files[i]; i++) {
$('#filesSize').append(f.name + ' - ' + f.size + '<br />');
var reader = new FileReader();
reader.onload = function (evt) {
var img = '<img src="' + evt.target.result + '"/>';
$('#images').append(img);
}
reader.readAsDataURL(f);
}
}
$('#FileUpload1').change(function (evt) {
showimages(evt.target.files);
});
</script>
http://www.itorian.com/2014/01/display-images-and-its-name-size-before.html
全站熱搜
留言列表