Click here to Skip to main content
15,889,116 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am trying to upload multiple files.. if user may upload 1 file then they may b go with submit button but if user wants to upload multiples files then they should click on upload more files and then next fileupload will be display how i do this.. i want to upload file separtely .. not want to select multiples at a time this is what i try

What I have tried:

ASP.NET
 <div>


        <asp:FileUpload ID="FileUpload1" runat="server" />
        <asp:LinkButton ID="LinkButton1" runat="server">upload multiple files</asp:LinkButton>
   
    <br />
    <asp:Button ID="Button1" runat="server" Text="upload" OnClick="Button1_Click" />
    <br />
    <asp:Label ID="Span1" runat="server"></asp:Label>
</div>



C#
protected void Button1_Click(object sender, EventArgs e)
       {
           if (FileUpload1.HasFiles)
           {
               foreach (HttpPostedFile uploadedFile in FileUpload1.PostedFiles)
               {
                   uploadedFile.SaveAs(System.IO.Path.Combine(Server.MapPath("~/Images/"),
                   uploadedFile.FileName));
                   Span1.Text += String.Format("{0}<br />", uploadedFile.FileName);
               }
           }
Posted
Updated 22-Dec-16 22:09pm

1 solution

 
Share this answer
 
Comments
super_user 23-Dec-16 5:05am    
they are using javascript and i dont want to use javascript or jquery .. . want to do this with only .net c#
super_user 23-Dec-16 5:06am    
this is using script or jquery.. i dont want to use this . use only c# ,net
super_user 23-Dec-16 5:17am    
........
super_user 24-Dec-16 15:57pm    
i dont want this.. i said i dont want multiple files selection at a time.. i want to select individual files.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900