.NET Web MVC 3 Multiple File upload limit

Multiple File Upload
MVC 3 - Multiple File Upload

There is a default limit on the file size (or total file size in the case of multiple files) of 4MB.

To increase it, add (or modify)

<httpRuntime maxRequestLength=”???” /> in Web.config

where “???” is the number of kilo bytes to permit in any upload.


Example: the default of 4MB is actually 4096 (KB). So to increase it to 40MB set maxRequestLength = 40960

 

Example

Controllers/DefaultController.cs

 

Views/Index.cshtml

 

If demonstrating this, use a html5 compliant browser that supports the multiple attribute of the <input type=”file” tag. Select a bunch of files that collectively will exceed a low maxRequestLength size limit. Observe that the submitFailed(…) JavaScript function is called, then increase the limit to verify.

I’m not sure if IE10 supports the ‘multiple’ attribute but certainly none of it’s preprocessors do (including IE9).

 

Anyway, be careful when increasing the limit because it can leave a site exposed to a Denial of Service Attack.

Multiple File Upload
MVC 3 - Multiple File Upload

Comments always welcome….

 

  • Johnny31

    perfect , simple and very helpful