Join the Stack Overflow Community
Stack Overflow is a community of 6.6 million programmers, just like you, helping each other.
Join them; it only takes a minute:
Sign up

I have a webpage(.aspx) which contains MULTIPLE FileUpload controls.

Default.aspx

<asp:FileUpload ID="FileUploadPort" runat="server" CssClass="Upload"  Multiple="Multiple"/>
<asp:FileUpload ID="FileUploadSearchImages" runat="server" CssClass="Upload"  Multiple="Multiple"/>

Default.aspx.cs

protected void btnSubmit_Click(object sender, EventArgs e)
{
       string filenm = string.Empty;
       HttpFileCollection fileCollection = Request.Files;
       for (int i = 0; i < fileCollection.Count; i++)
       {
           HttpPostedFile uploadfile = fileCollection[i];
           if (uploadfile.ContentLength > 0)
            {
              string filename = uploadfile.FileName;
              string imgFolder = ConfigurationManager.AppSettings["AdminSearchImgFolderPath"];
              System.Drawing.Image image = System.Drawing.Image.FromStream(uploadfile.InputStream); 
              image.Save(imgFolder + "\\" + GetSearchImageFileName("TEST"), ImageFormat.Jpeg);

             }
        }
    }

Here, Request.Files will get collectively all files from both the FileUploadControls.

I am NOT able to IDENTIFY which file(s) are from specific FileUpload control?

I know its possible in 4.5 but my current framework is 4.0 and i dont want to upgrade to 4.5. Any solution using existing 4.0 framework??

Help appreciated!

Please note: This is not DUPLICATE question as my requirement is to upload and identify the files of different fileupload controls on single page.

share|improve this question
    
Use if (FileUploadPort.HasFiles) to determine if the control has files and then continue to save the files. The process you can implement for the other fileupload control. This way you are able to identify which files are from a specific fileupload control. – Kami Apr 18 '16 at 14:12
    
This i have tried but how to get/iterate to files of specific fileupload control? Will you please post some code here...????? – SHEKHAR SHETE Apr 19 '16 at 4:07
    
Use this link. aspsnippets.com/Articles/… – Kami Apr 19 '16 at 14:18
    
Please read the post carefully. I have mentioned i am using 4.0 and not 4.5 framework :( – SHEKHAR SHETE Apr 20 '16 at 6:07
    
:) Ok, Take a look at this link, that might work for you. codeproject.com/Articles/667604/… – Kami Apr 20 '16 at 13:29

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.