Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/go/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net mvc 4 如何在ASP.NETMVC4中上传大文件_Asp.net Mvc 4_Upload_Large File Upload - Fatal编程技术网

Asp.net mvc 4 如何在ASP.NETMVC4中上传大文件

Asp.net mvc 4 如何在ASP.NETMVC4中上传大文件,asp.net-mvc-4,upload,large-file-upload,Asp.net Mvc 4,Upload,Large File Upload,如何在ASP.NETMVC4中上传大文件 我在控制器中有如下代码: Request.Files.Get(“img”).SaveAs(Server.MapPath(“~/Images/ImgSong/”++Out.Id+”.jpg”) 它只允许上传一个小文件,而我想上传的文件会 范围从10Mb到100Mb 请帮助我。根据文件大小编辑您的web.config <system.web> <compilation debug="true" targetFramework="4.

如何在ASP.NETMVC4中上传大文件

我在控制器中有如下代码:

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

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


请帮助我。

根据文件大小编辑您的
web.config

<system.web>
    <compilation debug="true" targetFramework="4.5" />
    <httpRuntime targetFramework="4.5" maxRequestLength="10240" executionTimeout="1600" requestLengthDiskThreshold="10240" />
    <security>
      <requestFiltering>
        <requestLimits maxAllowedContentLength="10240" />
      </requestFiltering>
    </security>
    ...
</system.web>

...

您需要更改web.config:

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


默认值为4096kb。您需要将此值更改为10240以进行10mb上载。

我必须按照您的指示执行操作,但仍然存在错误,这是图片![在此输入图像描述][1]此错误表示您在web.config上有标记,但没有configsections。如果不运行,你可以只使用我的代码,而不是只使用@Kamlesh的代码。顺便说一下,你已经使用了部分。你只需要写httpruntime的东西。