<%@ Import Namespace="System.IO"%>
<script language="VB" runat="server" >
sub Enter_click(sender As Object,E As EventArgs)
dim  Exc as Exception   '定义错误变量,用来捕获错误信息
try
dim filename,filepath as string
filename=path.GetFileName(uploadfile.postedfile.filename)
'filepath是服务器保存上传文件的完整路径
filepath=server.Mappath("upload") &  "\" & filename
uploadfile.PostedFile.SaveAs(filepath)  '保存上传文件到upload文件中
Response.Redirect("index.aspx")
catch Exc
  message.text="保存文件时出错<br>"& Exc.ToString()
  end try
end sub
</script>
<html>
<body>
<h4 align="center">上传文件</h4>
<form enctype="multipart/from-data" runat="server">
选择文件:<input id="uploadfile" type="file" runat="server">
<b><input type="button" id="enter" value="提交" onServerClick="Enter_click" runat="server">
<asp:label id="message" runat="server"/>
</form>
</body>
</html>