FileUpload.PostedFile Property

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

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

public:
property HttpPostedFile^ PostedFile {
	HttpPostedFile^ get ();
}
/** @property */
public HttpPostedFile get_PostedFile ()

public function get PostedFile () : HttpPostedFile

Not applicable.

Property Value

An HttpPostedFile for a file uploaded using the FileUpload.

The PostedFile property gets the underlying HttpPostedFile object for a file that is uploaded 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 code 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 System.Web.HttpPostedFile.ContentLength property. The ContentLength property is used to determine the length of the file prior to copying the file contents to a byte array.

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

Windows 98, Windows Server 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0

Community Additions

ADD
Show: