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>
  • 相关阅读:
    粘包_Server
    初见UDP_Server
    初见UDP_Client
    TCP/UDP协议
    网络编程相关概念
    mmap实现大文件快速拷贝
    生成这消费者问题(多线程实现)
    线程同步互斥实现资源访问
    信号灯(线程互斥)
    线程属性
  • 原文地址:https://www.cnblogs.com/xiaohaifengke/p/6008853.html
Copyright © 2011-2022 走看看