Dim MyPostedFile As HttpPostedFile = MyFileColl.Item(0)If LCase(MyPostedFile.ContentType.ToString()).IndexOf("image") < 0 Then Response.Write("无效的图形格式") End If
Dim MyPostedFile As HttpPostedFile = MyFileColl.Item(0)If LCase(MyPostedFile.ContentType.ToString()).IndexOf("image") < 0 Then Response.Write("无效的图形格式") End If ------------------------------------------------------------------------ 的方法.
Response.Write("无效的图形格式")
End If
function checkform()
{
if(getname(Form1.控件ID.value)!=".GIF")
{
alert("图片类型不正确!");
Form1.控件ID.focus();
return (false);
}
}function getname(path_name)
{
return path_name.substring(path_name.lastIndexOf(".")).toUpperCase();
}
</script>
function CheckImageFileIsValidate( photoFile, isUpload ){
var fileUpload = eval("document.all." + isUpload );
var postFile = eval( "document.all." + photoFile );
fileUpload.value = "true"; // 默认上传图片文件
strFileName = postFile.value;
var re = /^\s+|\s+$/g;
strFileName = strFileName.replace( re,"" );
if( strFileName == "" || strFileName.length < 5 ){
fileUpload.value = "false";
return true;
} var postfix = strFileName.substring( strFileName.length - 4, strFileName.length ).toUpperCase();
if( postfix != ".BMP" && postfix != ".JPG" && postfix != ".GIF" && postfix != ".PNG" ){
if(confirm("上传的图片格式无效!是否继续?")){
fileUpload.value = "false";
return true;
}
else
return false;
}
return true;
}
------------------------------------------------------------------------
回复人: gxboy(Blin 小学生学.NET) ( ) 信誉:65 2005-08-14 23:32:00 得分: 0
Dim MyPostedFile As HttpPostedFile = MyFileColl.Item(0)If LCase(MyPostedFile.ContentType.ToString()).IndexOf("image") < 0 Then
Response.Write("无效的图形格式")
End If
------------------------------------------------------------------------
的方法.
这样就会做到更好的安全性
代码楼上的都写好了,就不Copy了~