ASP.NET为我们提供了文件上传服务器控件FileUpload,默认情况下可上传的最大文件为4M,如果要改变可上传文件大小限制,那么我们可以在web.config中的httpRuntime元素中添加maxRequestLength属性设置大小,同时为了支持大文件上传超时可以添加executionTimeout属性设置超时时间。
Data from Msdn: https://msdn.microsoft.com/en-us/library/vstudio/e1f13641(v=vs.100).aspx
maxRequestLength | Optional Int32 attribute. Specifies the limit for the input stream buffering threshold, in KB. This limit can be used to prevent denial of service attacks that are caused, for example, by users posting large files to the server. The default is 4096 KB. If the threshold is exceeded, a ConfigurationErrorsException exception is thrown. |
Data from https://msdn.microsoft.com/en-us/library/ms689462(v=vs.90).aspx
Attribute | Description |
---|---|
maxAllowedContentLength | Optional uint attribute. Specifies the maximum length of content in a request, in bytes. The default value is 30000000. |
Data from http://forums.iis.net/t/1169846.aspx
The maxRequestLength indicates the maximum file upload size supported by ASP.NET, the maxAllowedContentLength specifies the maximum length of content in a request supported by IIS. Hence, we need to set both maxRequestLength and maxAllowedContentLength values to upload large files.
試過設置maxRequestLength=2048,可以實現附件大小限為2M。
http://www.cnblogs.com/wufengtinghai/p/3830695.html