这段代码起到了限制格式跟尺寸,我想让它能限制图片字节大小,那是就好了,请高手帮帮忙<Script language="javascript">
function mysubmit()
{
theform=document.form1;
if(theform.picture.value=="")
{
alert("请点击浏览按钮,选择您要上传的jpg或gif文件!")
theform.picture.focus;
return (false);
}
else
{
str= theform.picture.value;
strs=str.toLowerCase();
lens=strs.length;
extname=strs.substring(lens-4,lens);
if(extname!=".jpg" && extname!=".gif")
{
alert("请选择jpg或gif文件!");
return (false);
}
}
if(form1.img1.width>200 || form1.img1.height>100)
{
alert("您上传的图片尺寸太大,这样会影响美观!请裁剪后再上传!")
return(false);
}
}
</script>
<form name=form1 action="" method=post" onsubmit="return mysubmit();">
<input type="file" name="picture" onpropertychange="img1.src=this.value;">
<input type="submit" value="上传" name="B1" style="font-size: 12">
<img id="img1">
<P> </P>
</form>
function mysubmit()
{
theform=document.form1;
if(theform.picture.value=="")
{
alert("请点击浏览按钮,选择您要上传的jpg或gif文件!")
theform.picture.focus;
return (false);
}
else
{
str= theform.picture.value;
strs=str.toLowerCase();
lens=strs.length;
extname=strs.substring(lens-4,lens);
if(extname!=".jpg" && extname!=".gif")
{
alert("请选择jpg或gif文件!");
return (false);
}
}
if(form1.img1.width>200 || form1.img1.height>100)
{
alert("您上传的图片尺寸太大,这样会影响美观!请裁剪后再上传!")
return(false);
}
}
</script>
<form name=form1 action="" method=post" onsubmit="return mysubmit();">
<input type="file" name="picture" onpropertychange="img1.src=this.value;">
<input type="submit" value="上传" name="B1" style="font-size: 12">
<img id="img1">
<P> </P>
</form>
http://www.google.cn/search?hl=zh-CN&q=javascript%E5%88%A4%E6%96%AD%E4%B8%8A%E4%BC%A0%E5%9B%BE%E7%89%87%E7%9A%84%E5%A4%A7%E5%B0%8F%E5%92%8C%E6%A0%BC%E5%BC%8F