用HTML的File控件上传图片,用JS判断和限制图片格式、类型、尺寸
//判断图片类型
var f=document.getElementById("File1").value;
if(f=="")
{ alert("请上传图片");return false;}
else
{
if(!/\.(gif|jpg|jpeg|png|GIF|JPG|PNG)$/.test(f))
{
alert("图片类型必须是.gif,jpeg,jpg,png中的一种")
return false;
}
}
function CheckFile(f,p)
2}
1<input type="file" id="UpFile_Photo1" runat="server" name="UpFile_Photo1"
2size="35" onpropertychange="CheckFile(this.value,this)">小图<br />
3<input type="file" id="UpFile_Photo2" runat="server" name="UpFile_Photo2"
4size="35" onpropertychange="CheckFile(this.value,this)">中图<br />
5<input type="file" id="UpFile_Photo3" runat="server" name="UpFile_Photo3"
6size="35" onpropertychange="CheckFile(this.value,this)">大图<br />