问题描述:现在想上传一图片,并且想在客户端判断一下图片的大小是否满足要求,不想通过已经上传至服务器再取文件大小来判断,有好方法么?谢谢

解决方案 »

  1.   

    js好像不能获取客户端的图片信息
    除非你用active或者flash
      

  2.   

    <html><head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>cc</title>
    </head><body><form  method="post" name="myform1" enctype="multipart/form-data" >
      <input type="file" name="file1" size="20"  onchange="func()"/></form>
    <script>
    function func()
    {
    var oImg=new Image();
    oImg.src=myform1.file1.value;
     alert("width:"+oImg.width+"\nheight:"+oImg.height+"\nfilesize:"+(oImg.fileSize/1024).toFixed(1)+"k");
    }
    </script>
    </table> 
    </body></html>