Upload Multiple file in asp.net 4.5

Rajkatie
Posted by Rajkatie under ASP.NET category on | Points: 40 | Views : 3135
<asp:FileUpload ID="multipleFile" runat="server" AllowMultiple="true" />
<asp:Button ID="uploadFile" runat="server" Text="Upload files" onclick="uploadFile_Click"/>

In code behind

protected void uploadFile_Click(object sender, EventArgs e)
{
if (multipleFile.HasFiles)
{
foreach(HttpPostedFile uploadedFile in multipleFile.PostedFiles)
{
uploadedFile.SaveAs(Path.Combine(Server.MapPath("~/Images/"),uploadedFile.FileName));
Response.Write("Successfully file uploaded");
}
}
}

Comments or Responses

Login to post response