I have this code but is not compatible with 4.0, Thanks
.aspx
<div>
<asp:FileUpload runat="server" ID="UploadImages" Multiple="true" />
<asp:Button runat="server" ID="uploadedFile" Text="Upload" OnClick="uploadFile_Click" />
<asp:Label ID="listofuploadedfiles" runat="server" />
</div>
.cs
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);
}
}
}
I have this errors:
Error 1 'System.Web.UI.WebControls.FileUpload' does not contain a definition for 'HasFiles' and no extension method 'HasFiles' accepting a first argument of type 'System.Web.UI.WebControls.FileUpload' could be found (are you missing a using directive or an assembly reference?) And
Error 2 'System.Web.UI.WebControls.FileUpload' does not contain a definition for 'PostedFiles' and no extension method 'PostedFiles' accepting a first argument of type 'System.Web.UI.WebControls.FileUpload' could be found (are you missing a using directive or an assembly reference?)