- The following example demonstrates how to create a <xref:System.Web.UI.WebControls.FileUpload> control that saves files to a path that is specified in the code. The control limits the size of the file that can be uploaded to 5 MB. The <xref:System.Web.UI.WebControls.FileUpload.PostedFile%2A> property is used to access the underlying <xref:System.Web.HttpPostedFile.ContentLength%2A> property and return the size of the file. If the size of the file to upload is less than 2 MB, the <xref:System.Web.UI.WebControls.FileUpload.SaveAs%2A> method is called to save the file to the specified path on the server. In addition to checking for the maximum file size setting in your application code, you can set the `maxRequestLength` attribute of the [httpRuntime](https://msdn.microsoft.com/library/e9b81350-8aaf-47cc-9843-5f7d0c59f369) element to a maximum allowable size in the configuration file for your application.
0 commit comments