日期:2014-05-17  浏览次数:21004 次

如果上传图片太大了怎么报警呀!回复正确马上给分
<!DOCTYPE   HTML   PUBLIC   "-//W3C//DTD   HTML   4.0   Transitional//EN ">
<HTML>
<HEAD>
<TITLE>   New   Document   </TITLE>
</HEAD>
<script   language= "javascript ">
        <!--
//检查插入是否为图片
var   img=null;
function   chkimg(inp)
{
  if(img)img.removeNode(true);
  img=document.createElement( "img ");
  img.attachEvent( "onreadystatechange ",isimg);
  img.attachEvent( "onerror ",notimg);
  img.src=inp;
}
function   notimg()
{
  alert( "您插入的不是图片,请重新选择插入 ");
}
function   isimg()
{
  show.insertAdjacentElement( "BeforeEnd ",img);
  show1.innerHTML   =   "图片大小 "   +   img.fileSize/1024   + "K <br   /> 图片宽度 "+   img.offsetWidth   + " <br   /> 图片高度 "+   img.offsetHeight;

}

//   -->
</script>
<BODY>
<div   id= "show "> </div>
<div   id= "show1 "> </div>
<input   type= "file "   name= " "   onpropertychange= "chkimg(this.value) "/>
</BODY>
</HTML>
如果上传图片太大了怎么报警呀!!这个程序就没有报警,请问图片大小的值如何取得

------解决方案--------------------
function imgExceedSize()
{
//alert(document.postForm.tmpImg.width+ "===== "+document.postForm.tmpImg.height)

//if (document.postForm.tmpImg.width==0||document.postForm.tmpImg.height==0)

if(document.postForm.tmpImg.width> 150||document.postForm.tmpImg.height> 130)
{
alert( "图像尺寸: "+document.postForm.tmpImg.width+ " x "+document.postForm.tmpImg.height+ "。\r\n图像尺寸过大!请处理尺寸为 "+150+ " × "+130+ " 的图像,请重新浏览图片! ");
//document.postFOrm.tmpImg.value== " ";
return false;
}
}