FileUpload::PostedFile Property

 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

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)

public:
[BrowsableAttribute(false)]
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.

.NET Framework
Available since 2.0
Return to top
Show: