FileUpload.PostedFile Property
Assembly: System.Web (in system.web.dll)
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.