how do you do it?
Thanks!
how do you do it?
Thanks!
System.Web.HttpPostedFile and System.Web.HttpFileCollection
The ASP.Net pipeline already handles this for you. It becomes part of the request object. It should be in the Request.Form dictionary.
Check:
http://msdn.microsoft.com/en-us/library/system.web.httprequest.form.aspx
If you're using files you have to look at HttpPostedFile to get all the files that were uploaded.
Added
Or the Request.Files collection...
Markup:
<asp:FileUpload ID="FileUpload1" runat="server" Width="175"/>
<asp:Button ID="btnUpload" runat="server" CausesValidation="false"Text="Upload" OnClick="btnUpload_Click" />
<asp:Label ID="lblMsg" Visible="false" runat="server" Text=""></asp:Label>
Get a posted file in btnUpload_Click:
HttpPostedFile File = FileUpload1.PostedFile;
int i = File.ContentLength;
byte[] Data = new byte[i + 1];
File.InputStream.Read(Data, 0, File.ContentLength);
string sFileName = System.IO.Path.GetFileName(File.FileName.Replace(" ", "_"));
string p = Server.MapPath("~/images/");
File.SaveAs(p + sFileName);