如何在ASP.Net MVC 4中上传大文件

问题描述:

如何在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"));

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

它只允许上传一个小文件,而我要上传的文件会 范围从10Mb到100Mb.

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

请帮助我.

您需要更改web.config:

You need to change you web.config:

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

默认值为4096kb.您需要将此值更改为10240,才能上传10mb.

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