<%@ Page Language="C#" Debug="true" %> <script runat="server"> void btnUpload_OnClick(Object sender, EventArgs e) { HttpPostedFile myUpoad = Request.Files["myFile1"]; if(myUpoad.FileName.ToString() != "") { String strFileName = System.IO.Path.GetFileName(myUpoad.FileName); myUpoad.SaveAs(Server.MapPath("Myfiles/" + strFileName)); this.lblText.Text = strFileName + " Uploaded.<br>"; } } </script> <html> <head> <title>ThaiCreate.Com ASP.NET - Upload files</title> </head> <body> <form id="form1" runat="server" enctype="multipart/form-data"> <input name="myFile1" type="file"> <input id="btnUpload" type="button" OnServerClick="btnUpload_OnClick" value="Upload" runat="server" /> <hr /> <asp:Label id="lblText" runat="server"></asp:Label> </form> </body> </html>
ช่วยกันสนับสนุนรักษาเว็บไซต์ความรู้แห่งนี้ไว้ด้วยการสนับสนุน Source Code 2.0 ของทีมงานไทยครีเอท