最简单的文件上传代码

来源:互联网 发布:淘宝充值王者荣耀点券 编辑:程序博客网 时间:2024/06/04 17:47
<%@ Page Language="VB" ContentType="text/html" ResponseEncoding="gb2312" %>
<%@ import Namespace="System" %>
<%@ import Namespace="System.IO" %>
<script runat="server">
sub Button_Click(sender as Object,e as EventArgs)
dim path as string
path = Server.MapPath("Uploads/aaa.jpg")
uploadFile.PostedFile.SaveAs(path)
end sub
</script>
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>
<body>
<form method="post" enctype="multipart/form-data" runat="server">
<p>
<input id="uploadFile" type="file" runat="server" />
<asp:Label id="lblErrInfo" runat="server" forecolor="Red"></asp:Label>
</p>
<p>
<input id="button" type="button" value="上传" onServerClick="Button_Click" runat="server" />
</p>
<p><asp:Image id="ImgPreview" runat="server"></asp:Image>
</p>
</form>
</body>
</html>
 
原创粉丝点击