See Also: HttpPostedFile Members
The System.Web.HttpFileCollection class provides access to all the files that are uploaded from a client as a file collection. The System.Web.HttpPostedFile class provides properties and methods to get information about an individual file and to read and save the file.
The System.Web.UI.HtmlControls.HtmlInputFile control can be used to select and upload files from a client.
Files are uploaded in MIME multipart/form-data format. By default, all requests, including form fields and uploaded files, larger than 256 KB are buffered to disk, rather than held in server memory.
You can specify the maximum allowable request size by accessing the System.Web.Configuration.HttpRuntimeSection.MaxRequestLength property or by setting the maxRequestLength attribute of the httpRuntime Element (ASP.NET Settings Schema) element within the Machine.config or Web.config file. The default is 4 MB.
The amount of data that is buffered in server memory for a request, which includes file uploads, can be specified by accessing the System.Web.Configuration.HttpRuntimeSection.RequestLengthDiskThreshold property or by setting the requestLengthDiskThreshold attribute of the httpRuntime Element (ASP.NET Settings Schema) element within the Machine.config or Web.config file.
By adjusting the System.Web.Configuration.HttpRuntimeSection.MaxRequestLength and System.Web.Configuration.HttpRuntimeSection.RequestLengthDiskThreshold properties, you can fine tune the performance of your server. Additionally, you should consider setting the System.Web.Configuration.HttpRuntimeSection.MaxRequestLength to prevent denial of service attacks caused by users posting large files to the server.
Server resources that are allocated to buffer the uploaded file will be destroyed when the request ends. To save a durable copy of the file, use the HttpPostedFile.SaveAs(string) method.