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

    1.采用客户端javascript可以取得图片大小
    <input id="FileUpload" type="file" size="30" name="FileUpload" onpropertychange="javascript:img2.src=this.value;">
    <img id="img2" src="" style="visibility:hidden;position:absolute;top=-10000"/>
    <input type="button" value="获取" onclick="javascript:abc();"> 

    <script type="text/javascript">
            function abc() {
                alert(img2.width);
            }
        </script>

    2.采用流取得图片大小
    Stream stream=file.PostedFile.InputStream;
    System.Drawing.Image image=System.Drawing.Image.FromStream(stream);

    int picWidth= image.Width;
    int picheight= image.Height;
    3.使用文件得到图片大小
    System.Drawing.Image image=System.Drawing.Image.FromFile(物理路径)

     int picWidth= image.Width;
    int picheight = image.Height;

  • 相关阅读:
    mysql性能优化
    pymysql模块
    mysql数据表约束
    MySQL数据库
    IO模型
    8451
    8946531
    6783
    256213
    27822
  • 原文地址:https://www.cnblogs.com/keanuyaoo/p/3315616.html
Copyright © 2011-2022 走看看