zoukankan      html  css  js  c++  java
  • javascript获取上传图片的大小

    javascript获取上传图片的大小

    <pre>
    <input id="file" type="file">
    <input id="Button1" type="button" value="button" onclick="check()">
    <script>
    window.check=function(){
    var input = document.getElementById("file");
    if(input.files){
    //读取图片数据
    var f = input.files[0];
    var reader = new FileReader();
    reader.onload = function (e) {
    var data = e.target.result;
    //加载图片获取图片真实宽度和高度
    var image = new Image();
    image.onload=function(){
    var width = image.width;
    var height = image.height;
    alert(width+'======'+height+"====="+f.size);
    };
    image.src= data;
    };
    reader.readAsDataURL(f);
    }else{
    var image = new Image();
    image.onload =function(){
    var width = image.width;
    var height = image.height;
    var fileSize = image.fileSize;
    alert(width+'======'+height+"====="+fileSize);
    }
    image.src = input.value;
    }
    }
    </script>
    </pre>

  • 相关阅读:
    CF899A Splitting in Teams
    CF898A Rounding
    CF914A Perfect Squares
    CF864A Fair Game
    CF909A Generate Login
    关于C++的一些函数的使用方法
    又是一个二模02,不过day2
    2模02day1题解
    二模Day2题解
    KMP算法心得
  • 原文地址:https://www.cnblogs.com/newmiracle/p/11856303.html
Copyright © 2011-2022 走看看