HTML 部分 <!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> <title>HTML控件配合ASP。NET 上传</title> </head> <body> <form name="uploadForm" method="post" enctype="multipart/form-data" action="Default.aspx"> <input type="file" id="imgFile" name="imgFile" style="width:220px;" /> <input type="submit" value="上传" /> </form> </body> </html> Default.aspx.cs using System; using System.Data; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using System.IO; public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if (!this.IsPostBack) { HttpPostedFile file = Request.Files["imgFile"];//获得上传控件对象 file.SaveAs(Server.MapPath("~/Upload/"+DateTime.Now.ToString("yyyyMMddHHmmssff")+new FileInfo(file.FileName).Extension)); } } }