Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.71 KB | None | 0 0
  1. <asp:FileUpload ID="fuAttach" Multiple="Multiple" runat="server" Visible="False" />
  2.  
  3. '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?)
  4.  
  5. public class FileUpload : WebControl
  6. {
  7. public FileUpload();
  8.  
  9. public byte[] FileBytes { get; }
  10. public Stream FileContent { get; }
  11. public string FileName { get; }
  12. public bool HasFile { get; }
  13. public HttpPostedFile PostedFile { get; }
  14.  
  15. protected override void AddAttributesToRender(HtmlTextWriter writer);
  16. protected internal override void OnPreRender(EventArgs e);
  17. protected internal override void Render(HtmlTextWriter writer);
  18. public void SaveAs(string filename);
  19. }
  20.  
  21. <asp:FileUpload runat="server" ID="UploadImages" AllowMultiple="true" />
  22.  
  23. <div>
  24. <asp:FileUpload runat="server" ID="UploadImages" AllowMultiple="true" />
  25. <asp:Button runat="server" ID="uploadedFile" Text="Upload" OnClick="uploadFile_Click" />
  26. <asp:Label ID="listofuploadedfiles" runat="server" />
  27. </div>
  28.  
  29. protected void uploadFile_Click(object sender, EventArgs e)
  30. {
  31. if (UploadImages.HasFiles)
  32. {
  33. foreach (HttpPostedFile uploadedFile in UploadImages.PostedFiles)
  34. {
  35. uploadedFile.SaveAs(System.IO.Path.Combine(Server.MapPath("~/Images/"),
  36. uploadedFile.FileName)); listofuploadedfiles.Text += String.Format("{0}<br />", uploadedFile.FileName);
  37. }
  38. }
  39. }
  40.  
  41. dynamic fileUploadControl = fileUpload1;
  42. foreach(var file in fileUploadControl.PostedFiles)
  43. {//do things here}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement