<%@ Page Language="C#" Debug="true" %> <script runat="server"> void btnUpload_OnClick(Object sender, EventArgs e) { int i; FileUpload myUpoad; for( i = 1; i <= 5; i++) { myUpoad = (FileUpload)this.FindControl("fiUpload"+i); if(myUpoad.HasFile) { myUpoad.SaveAs(Server.MapPath("Myfiles/" + myUpoad.FileName)); this.lblText.Text = this.lblText.Text + System.IO.Path.GetFileName(myUpoad.FileName) + " Uploaded.<br>"; } } } </script> <html> <head> <title>ThaiCreate.Com ASP.NET - Upload files</title> </head> <body> <form id="form1" runat="server"> <asp:FileUpload id="fiUpload1" runat="server"></asp:FileUpload><br /> <asp:FileUpload id="fiUpload2" runat="server"></asp:FileUpload><br /> <asp:FileUpload id="fiUpload3" runat="server"></asp:FileUpload><br /> <asp:FileUpload id="fiUpload4" runat="server"></asp:FileUpload><br /> <asp:FileUpload id="fiUpload5" runat="server"></asp:FileUpload> <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 ของทีมงานไทยครีเอท