tags:

views:

175

answers:

3

how do you do it?

Thanks!

+1  A: 

System.Web.HttpPostedFile and System.Web.HttpFileCollection

richardtallent
+1  A: 

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...

Min
the post is coming from a flash object that captures an image and sends via POST.
Martin Ongtangco
You should edit your initial question with that information. I had no idea where you were coming from.
Min
+1  A: 

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);
rick schott