ASP.net上传失败与大尺寸的文件 [英] ASP.net upload fails for files with large size

查看:117
本文介绍了ASP.net上传失败与大尺寸的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经创建了ASP.net一个简单的电影网站,但只接受小型文件上传。在code看起来是这样的(这部分是刚下上传click事件):

I have created a simple movie website with ASP.net, but it only accepts small-sized files for uploads. The code looks like this (this part is just under the upload click event):

HttpPostedFile file = FileUpload1.PostedFile;
// Saving Files on Local folder
file.SaveAs(Server.MapPath("~/Videos/") + file.FileName);
string connectionString = ConfigurationManager.AppSettings["constr"];
connection = new SqlConnection(connectionString);
SqlCommand cmd = new SqlCommand("INSERT INTO movieTable(Title,UploadDate)VALUES (@filme,@mydatetime)", connection);
cmd.Parameters.AddWithValue("@filme", FileUpload1.FileName);
cmd.Parameters.Add("@mydatetime", DateTime.Now.ToString());

当我尝试上传一个大的视频文件,它给了我否定错误的访问。任何帮助是AP preciated。谢谢

When I try to upload a large video file, it gives me an access denied error. Any help is appreciated. Thanks

推荐答案

您的服务器可能有文件可以接受上传的大小有限制。

Your server may have a limit on the size of files it can accept for uploading.

显然,没有在的machine.config 设置一个4MB的默认限制,但你可以在你重写它的web.config 。例如,这增加了上传限制为20MB:

Apparently, there is a 4MB default limit set in machine.config, but you can override it in you web.config. For example, this increases the upload limit to 20MB:

<system.web>
  <httpRuntime executionTimeout="240" maxRequestLength="20480" />
</system.web>

您可以阅读更多有关的大文件上传ASP.NET

You can read more about large file uploads in ASP.NET.

这篇关于ASP.net上传失败与大尺寸的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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