标签:
Default.aspx
<html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <title>文件上传测试</title> </head> <body> <form id="form1" runat="server"> <div> <asp:FileUpload ID="FileUpload1" runat="server" /> <asp:Button ID="BtnUpload" runat="server" Text="上传" OnClick="BtnUpload_Click" /> </div> </form> </body> </html>
Default.aspx.cs
protected void BtnUpload_Click(object sender, EventArgs e) { string path = "c:\\pdfword\\"; if (FileUpload1.HasFile) { try { FileUpload1.SaveAs(path + FileUpload1.FileName); } catch (Exception ex) { Response.Write(ex.Message); } } }
标签:
原文地址:http://www.cnblogs.com/aoun/p/4419019.html