If the client uses multipart/form-data
request encoding (which is the standard for uploading files) you could retrieve the uploaded file from the Request.Files
collection. For example:
protected void Page_Load(object sender, EventArgs e)
{
foreach (HttpPostedFile file in Request.Files)
{
var fileName = Path.GetFileName(file.FileName);
var path = Path.Combine(Server.MapPath("~/App_Data/uploads"), fileName);
file.SaveAs(path);
}
}
or if you know the name used by the client you could directly access it:
HttpPostedFile file = Request.Files["file"];
If on the other hand the client doesn't use a standard encoding for the request you might need to read the file from the Request.InputStream
.