FileUpload Contol not showing posted files

Go to "Application" tab in the project "Properties" and change the "Target Framework" to 4.5.


I probably come too late, but since I am having the same problem. I decide to post my answer here for any future answer seekers. I have to use a walk-around to tackle this problem.

dynamic fileUploadControl = fileUpload1;
foreach(var file in fileUploadControl.PostedFiles)
{//do things here}

converting your fileUpload userControl to a dynamic object will allow you to bypass the compile time error checking.


It should be something like this :

<asp:FileUpload runat="server" ID="UploadImages" AllowMultiple="true" />

html code will be like this :

<div>
    <asp:FileUpload runat="server" ID="UploadImages" AllowMultiple="true" />
    <asp:Button runat="server" ID="uploadedFile" Text="Upload" OnClick="uploadFile_Click" />
    <asp:Label ID="listofuploadedfiles" runat="server" />
</div>

code behind for the upload button :

protected void uploadFile_Click(object sender, EventArgs e)
{
   if (UploadImages.HasFiles)
   {
       foreach (HttpPostedFile uploadedFile in UploadImages.PostedFiles)
       {
           uploadedFile.SaveAs(System.IO.Path.Combine(Server.MapPath("~/Images/"),
           uploadedFile.FileName)); listofuploadedfiles.Text += String.Format("{0}<br />", uploadedFile.FileName);
       }
   }
}