'How to upload multiple files using multiple fileupload controls in asp.net?
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.
Solution 1:[1]
You can add an extension method to get the same effect as .Net 4.5 as in this answer:
https://stackoverflow.com/a/30360786
[ note: I can't comment that's why i posted this as an answer ]
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
