废话不说  直接上代码

<script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<body>
 <img id="image" src=""/>
<br/>
 <input type="file" id="file" onchange="selectImage(this);"/> <br>
<br/>
<script>
    function selectImage(file) {
        alert(file.value.substring(file.value.lastIndexOf('.')));
        if (!file.files || !file.files[0]) {
            return;
        }
        var reader = new FileReader();
        reader.onload = function (evt) {
            var data = evt.target.result;  
            //加载图片获取图片真实宽度和高度  
            var image = new Image();  
            image.onload=function(){  
                var width = image.width;  
                var height = image.height;  
                alert(width+'======'+height+"====="+file.files[0].size+'1');  
            };  
            image.src= data;  
            document.getElementById('image').src = evt.target.result;
        }

        reader.readAsDataURL(file.files[0]);
        $("#image").attr({'width':'100px','height':'100px'});
    }

</script>
</body>
</html>

最新文章

  1. ES6(二)解构赋值详解
  2. iOS学习36数据处理之SQLite数据库
  3. access里like的通配符不能用%,要用*
  4. Net Core- 配置组件
  5. linux grep命令详解(转)
  6. [leetcode-357-Count Numbers with Unique Digits]
  7. 最简单获取appPackage和appActivity 的方法
  8. js滚动到指定位置
  9. [luogu P2054] [AHOI2005]洗牌
  10. Android分组子级的不同视图布局之BUG奇遇记
  11. 09 Go 1.9 Release Notes
  12. JSP字符集编码集合
  13. Java中-classpath和路径的使用
  14. java中如何打war包
  15. BZOJ4145_The Prices_KEY
  16. PSP Daily软件beta版本——基于spec评论
  17. 【BZOJ】3991: [SDOI2015]寻宝游戏 虚树+DFS序+set
  18. 3D Math Keynote
  19. hadoop3.1 hdfs的api使用
  20. delphi xe5 安卓 配置sqlite

热门文章

  1. C++中vector 容器的基本操作
  2. windows中如何查看某个端口被谁占用
  3. @dynamic 与 @synthesize
  4. jQuery获取URL中所带参数的办法
  5. 自用LogSystem入库分享
  6. OGG学习笔记03-单向复制简单故障处理
  7. Git学习之路(3)-提交文件到三个区
  8. 吉特仓储管系统(开源)--使用Grunt压缩JS文件
  9. WinForm 控件(上)
  10. ECMAScript 6 笔记(五)