zoukankan      html  css  js  c++  java
  • 用jquery来获得上传图片的尺寸

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>用jquery来获得上传图片的尺寸的</title>
    </head>
    <body>
        <input type="file" id="image_file" multiple>
        <script src="./lib/jquery-1.8.0.min.js"></script>
        <script>
            //获取input图片宽高和大小
            function getImageWidthAndHeight(id, callback) {
              var _URL = window.URL || window.webkitURL;
              $("#" + id).change(function (e) {
                var file, img;
                if ((file = this.files[0])) {
                  img = new Image();
                  img.onload = function () {
                    callback && callback({"width": this.width, "height": this.height, "filesize": file.size});
                  };
                  img.src = _URL.createObjectURL(file);
                }
              });
            }
            
            getImageWidthAndHeight('image_file', function (obj) {
               console.log(''+obj.width+'-----height:'+obj.height);
              });
        </script>
        <script></script>
    </body>
    </html>
  • 相关阅读:
    日期类和包装类
    集合——list
    数组
    多态小结
    一些概念性的知识点
    简单的图书管理系统
    一个小总结
    python-web自动化:上传操作
    python-web自动化:日期框操作
    python-web自动化:滚动条
  • 原文地址:https://www.cnblogs.com/xiaohaifengke/p/6008853.html
Copyright © 2011-2022 走看看