</tr>
</table>
</div>
</form>
</body>
</html>
3.客户端检查上传文件类型(以上传图片为例)
效果图:
后台代码和1.最简单的单文件上传一样;
前台代码:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>清清月儿 http://blog.csdn.net/21aspnet</title>
<script language="javascript">
function Check_FileType()
{
var str=document.getElementById("FileUpload1").value;
var pos = str.lastIndexOf(".");
var lastname = str.substring(pos,str.length)
if (lastname.toLowerCase()!=".jpg" && lastname.toLowerCase()!=".gif")
{
alert("您上传的文件类型为"+lastname+",图片必须为.jpg,.gif类型");
return false;
}
else
{
return true;
}
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<table style="width: 343px">
<tr>
<td style="width: 104px">
文件上传判断</td>
<td style="width: 100px">
</td>
</tr>
<tr>
<td style="width: 104px">
<asp:FileUpload ID="File