Skip to content

2 multifile upload

alaa

Asked Sep 2, 2014, 11:48 AM EDT2 answers
Share
LinkedInX
hi every body 
how can i use 2 multifile upload in the same page
i had try this code
protected void uploadFile_Click(object sender, EventArgs e)
{
if (UploadImages1.HasFiles)
{
foreach (HttpPostedFile uploadedFile in UploadImages1.PostedFiles)
{
uploadedFile.SaveAs(System.IO.Path.Combine(Server.MapPath("~/Images/"),
uploadedFile.FileName)); listofuploadedfiles.Text += String.Format("{0}<br />", uploadedFile.FileName);
}
}
 
if (UploadImages2.HasFiles)
{
foreach (HttpPostedFile uploadedFile in UploadImages2.PostedFiles)
{
uploadedFile.SaveAs(System.IO.Path.Combine(Server.MapPath("~/Images2/"),
uploadedFile.FileName)); listofuploadedfiles.Text += String.Format("{0}<br />", uploadedFile.FileName);
}
}

}
 
but they count the all photos despite they are different the 2 file upload count the all photos on page
how can solve this problem ? 

2 Answers

Know the answer? Post it. Somebody with the same question will find it here.

  • 0
    #1: you can append something alongwith filename while uploading, e.g.,
    file1_upload1.jpg
    file1_upload2.jpg

    now when you're counting you can separate based on _upload1 & _upload2

    #2: while uploading you can upload in two different folders. so you know which is upload 1 and which is upload2

    Please click checkbox "This is correct answer" if you find it helpful!
    0
  • 0
    i raelly make separted folder for them can u make it claer by edite my code ?
    0