This documentation is archived and is not being maintained.

FileUpload::PostedFile Property

Gets the underlying HttpPostedFile object for a file that is uploaded by using the FileUpload control.

Namespace:  System.Web.UI.WebControls
Assembly:  System.Web (in System.Web.dll)

[BrowsableAttribute(false)]
public:
property HttpPostedFile^ PostedFile {
	HttpPostedFile^ get ();
}

Property Value

Type: System.Web::HttpPostedFile
An HttpPostedFile for a file uploaded by using the FileUpload.

The PostedFile property gets the underlying HttpPostedFile object for a file that is uploaded by using the FileUpload control. Use this property to access additional properties on the uploaded file.

You can use the ContentLength property to get the length of the file. You can use the ContentType property to get the MIME content type of the file. In addition, you can use the PostedFile property to access the FileName property, the InputStream property, and the SaveAs method. However, the same functionality is provided by the FileName property, the FileContent property, and the SaveAs method.

The following example demonstrates how to create a FileUpload control. When the user clicks the Upload file button, the contents of the file are displayed as bytes in a text box on the page. This example uses the PostedFile property to access the HttpPostedFile::ContentLength property. The ContentLength property is used to determine the length of the file before copying the file contents to a byte array.

No code example is currently available or this language may not be supported.

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0
Show: