• [转]前台JS限制上传图片质量大小和尺寸!


    转自:

         http://hi.baidu.com/vivicode/blog/item/c53d392ec9038f564ec2264a.html

    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=??????">
    <script language="javascript">
    <!--
    function imgSel()
    {
    var img = new Image();
    img.src = document.imageForm.file.value;
    document.imageForm.width.value = img.width;
    document.imageForm.height.value = img.height;
    document.imageForm.size.value = img.fileSize;
    document.images['image'].src = img.src;
    }
    -->
    </script>
    </head>
    <body>
    <form name="imageForm">
    宽: <input name="width" type="text" size="6"> 高: <input name="height" type="text" size="6"> 大小: <input name="size" type="text" size="6"><br>
    <input name="file" type="file" onChange="imgSel()"><br>
    <img src="" name="image">
    </form>
    </body>
    </html>

     转自:http://hi.baidu.com/top147/blog/item/f7c3023f641ec0ed54e723b1.html

     <HTML><HEAD> 
    <SCRIPT> 
    // JS 判断文件大小

    function   getFileSize   (fileName)   { 
      
    if   (document.all)   { 
    window.oldOnError   =   window.onerror;         
    window.onerror   =   function   (err)   { 
    if   (err.indexOf('utomation')   !=   -1)   { 
    alert('没有访问文件的权限');                 
    return   true;             
    }           
    else   
    return   false;         
    }; 
            var   fso   =   new   ActiveXObject('Scripting.FileSystemObject'); 
            var   file   =   fso.GetFile(fileName);         
    window.onerror   =   window.oldOnError; 
            return   file.Size;     }} 
    </SCRIPT> 
    </HEAD> 
    <BODY> 
    <FORM   NAME="formName"><INPUT   TYPE="file"   NAME="fileName"><BR> 
    <INPUT   TYPE="button"   VALUE="查看文件字节大小"   ONCLICK="alert(getFileSize(this.form.fileName.value))"><BR> 
    </FORM></BODY> 
    </HTML>  

  • 相关阅读:
    运用《深入理解Java虚拟机》书中知识解决实际问题
    FPGA实现移动目标检测
    FPGA实现人脸检测
    FPGA实现图像的边缘检测:灰度形态学梯度
    FPGA实现图像的二值形态学滤波:边界提取
    VAST3.0规范
    Flash Socket通信的安全策略问题 843端口
    100个开源游戏
    游戏指标分析
    网络广告类型有哪些?
  • 原文地址:https://www.cnblogs.com/xjyggd/p/1335234.html
Copyright © 2020-2023  润新知