asp.net-mvc-4uploadlarge-file-upload

How to upload large files in ASP.Net MVC 4


How to upload large files in ASP.Net MVC 4

I have code like this in the controller:

Request.Files.Get("img").SaveAs(Server.MapPath("~/Images/ImgSong/" + +Out.Id + ".jpg"));

It only allows uploading a small file, while the file I want to upload would range from 10Mb to 100Mb.

Please help me.


Solution

  • You need to change you web.config:

    <configuration>
      <system.web>
        <httpRuntime maxRequestLength="4096" />
      </system.web>
    </configuration>
    

    The default value is 4096kb. You need to change this value to 10240 for 10mb uploading.