welcome Netizen

Share Your Knowledge.It is a way to achieve immortality

Sunday, March 17, 2013

Multiple file upload in

Here I would like to share a code to upload multiple files using framework 4.0.In a previous I had post article related to multiple file upload control. For your reference below I have mention the link..
In latest framework file upload control has a default properties to upload multiple, just we need to enable the properties
Drag the file upload control and one button
Write the below code on the button event to upload multiple files on the server
           <asp:FileUpload ID="FileUpload2" runat="server"  />
        <asp:FileUpload ID="FileUpload1" runat="server"  multiple="multiple" />
        <br />
        <asp:Button ID="btnUpload" runat="server" Text="Upload All"
            onclick="btnUpload_Click" />

Server code:
protected void btnUpload_Click(object sender, EventArgs e)
            // Get the HttpFileCollection
            HttpFileCollection Filecll = Request.Files;
            for (int i = 0; i < Filecll.Count; i++)
                HttpPostedFile hpf = Filecll[i];
                if (hpf.ContentLength > 0)
                    hpf.SaveAs(Server.MapPath("Images") + "\\" + System.IO.Path.GetFileName(hpf.FileName));
                    Response.Write("<b>File: </b>" + hpf.FileName + " <b>Size:</b> " +
                        hpf.ContentLength + " <b>Type:</b> " + hpf.ContentType + " Uploaded Successfully <br/>");
        catch (Exception ex)


Selected file has been moved to server images folder.
Note: when doing selection you need to select multiple file or single file to upload…
Click here to Download project file
Post your comments………


Post a Comment