Click here to Skip to main content
15,887,585 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Helloo,

I want to make file upload with the multiple file attachment and then i send all that uploaded file to the selected user as attachment.

but how to make file upload same as gmail have.

please give me some help in this metter.

Thanks and Regards...
Mitesh
Posted

1 solution

hi, you are looking for something like this:
ASP.NET
<asp:fileupload id="multipleFile" runat="server" allowmultiple="true" xmlns:asp="#unknown" />
<asp:button id="uploadFile" runat="server" text="Upload files" onclick="uploadFile_Click" xmlns:asp="#unknown" />


C#
protected void uploadFile_Click(object sender, EventArgs e)
{
    if (multipleFile.HasFiles)
    {
        foreach(HttpPostedFile uploadedFile in multipleFile.PostedFiles)
        {
            uploadedFile.SaveAs(System.IO.Path.Combine(Server.MapPath("~/Images/"),uploadedFile.FileName));
            Response.Write("File uploaded successfully");
        }
    }
}
 
Share this answer
 
Comments
[no name] 4-Oct-12 5:12am    
it is possible to write this code on submit button click event. and do same as your code say.
tanweer 4-Oct-12 5:16am    
if your sumbit button is a server control then you can definitely write this code
[no name] 4-Oct-12 5:23am    
also gives error on Foreach statement as "foreach statement cannot operate on variables of type 'System.Web.HttpPostedFile' because 'System.Web.HttpPostedFile' does not contain a public definition for 'GetEnumerator'"
tanweer 4-Oct-12 7:12am    
i am working with asp.net 4.5 and Visual Studio 2012

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