<%@ Page Language="C#" Debug="true" %> <script runat="server"> void btnUpload_OnClick(Object sender, EventArgs e) { int i; HttpFileCollection myUpoad = Request.Files; HttpPostedFile myFiles; this.lblText.Text = ""; for(i = 0; i<= myUpoad.Count - 1; i++) { myFiles = (HttpPostedFile)myUpoad[i]; if(myFiles.FileName.ToString() != "") { String strFileName = System.IO.Path.GetFileName(myFiles.FileName); myFiles.SaveAs(Server.MapPath("Myfiles/" + strFileName)); this.lblText.Text = 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="myFile" type="file"><br /> <input name="myFile" type="file"><br /> <input name="myFile" type="file"><br /> <input name="myFile" type="file"><br /> <input name="myFile" type="file"><br /> <input name="myUpload" type="file"><br /> <input name="myUpload" type="file"><br /> <input name="myUpload" type="file"><br /> <input name="myUpload" type="file"><br /> <input name="myUpload" 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 ของทีมงานไทยครีเอท