I am trying to make a server page (C#, asp.net 2.0+) to save an uploaded file from another page.
Specifically, I have an HTML page with a
I made a small test case:
Uploader.aspx markup:
Codebehind from Upload.aspx:
protected void Page_Load(object sender, EventArgs e)
{
FileUpload fu = PreviousPage.FindControl("fuTest") as FileUpload;
if (fu != null)
{
int length = fu.PostedFile.ContentLength;
}
}
The PostBackUrl property of the button posts it to the Upload.aspx page. There you can use the PreviousPage property of the Page class to find the control from the previous page, cast it to FileUpload, and retrieve what you want from it.