如何在ASP.Net MVC 4中上传大文件 [英] How to upload large files in ASP.Net MVC 4

查看:178
本文介绍了如何在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.

这篇关于如何在ASP.Net MVC 4中上传大文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆