<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>New Page 1</title>
</head><body>
<script>
<!--
function chkimg(src)
{
var checkImg = new Image();
checkImg.onload =new Function("alert(this.width>400?'图象大小为:'+this.width+'*'+this.height+',宽度超出400!':'图象大小为:'+this.width+'*'+this.height+',宽度未超出400!')")
checkImg.src =src;
}
//-->
</script>
<input type="file" name="myImg" size="20" onpropertychange="chkimg(this.value);"></body></html>

解决方案 »

  1.   

    <script language="javascript">
    var img=null;
    function s()
    {
      if(img)img.removeNode(true);
      img=document.createElement("img");
      img.style.position="absolute";
      img.style.visibility="hidden";
      img.attachEvent("onreadystatechange",orsc);
      img.attachEvent("onerror",oe);
      document.body.insertAdjacentElement("beforeend",img);
      img.src=document.product.FilePath.value;
    }
    function oe()
    {
      alert("上传图片类型为:GIF、JPEG/JPG、BMP");
    }
    function orsc()
    {
      if(img.readyState!="complete")return false;
     else
       alert(img.fileSize)
    }
    </script>
    </head><body leftmargin="0" topmargin="0">
    上传图片<input type=file name="FilePath" size=8 onpropertychange="return s();">