Answer: In ASP.NET simultaneously on the server we can use multiple files to upload file
Example :
ASPX PAGE :
Upload files<br />
<asp:FileUpload ID="FileUpload1" runat="server" /><br />
<asp:FileUpload ID="FileUpload2" runat="server" /><br />
<asp:FileUpload ID="FileUpload3" runat="server" /><br />
<asp:FileUpload ID="FileUpload4" runat="server" /><br />
<p><asp:Button ID="btnUpload" runat="server" Text="Upload Multiple Files" OnClick="UploadMultipleFiles" /></p>
Code behind :
protected void UploadMultipleFiles(object sender, EventArgs e)
{
HttpFileCollection files = Request.Files;
for (int i = 0; i < files.Count; i++)
{
HttpPostedFile file = files[i];
string path = Server.MapPath("~/");
string fileName = file.FileName;
file.SaveAs(path + fileName);
Response.Write(fileName + " uploaded successfully ! <br />");
}
}
Asked In: While Learning |
Alert Moderator