Wednesday, March 25, 2015

Upload Multiple file

It’s new inbuld feature of fileupload control in .net framework 4.5
Place file upload control and set propert allow multiple file
<asp:FileUpload ID="FileUpload1" runat="server" AllowMultiple="True"
/>
protected void Button1_Click(object sender, EventArgs e)
{
      if (FileUpload1.HasFiles)
      {
// Iterate over files
              foreach (HttpPostedFile file in FileUpload1.PostedFiles)
             {
                     file.SaveAs(Server.MapPath("~/files/") + file.FileName);
             }
              lblMsg.Text = "Uploaded " + FileUpload1.PostedFiles.Count + " files!";
       }
}

No comments:

Post a Comment