c#上传视频失败
本文关键字:失败 视频 | 更新日期: 2023-09-27 18:10:11
这是我在服务器上上传视频的代码
protected void Button1_Click(object sender, EventArgs e)
{
if (FileUpload1.HasFile)
{
string fileName = FileUpload1.FileName;
string fileExtension = Path.GetExtension(fileName);
if (fileExtension == ".flv")
{
if (!File.Exists(Path.Combine(Server.MapPath("~/Video"), fileName)))
{
string fullFileName = Path.Combine(Server.MapPath("~/Video1"), fileName);
FileUpload1.SaveAs(fullFileName);
Label1.Text = "The file has been uploaded";
}
else
{
Label1.Text = "The file already exist! You must delete old version first in order to upload new version";
}
}
else
{
Label1.Text = "The file format is not allow";
}
}//else if
else
{
Label1.Text = "please select a file to upload";
}
}
一切都很顺利,但是当我上传.FLV
文件时,它在网页上返回了一个错误信息,这里是错误代码
输出:Error 101 (net::ERR_CONNECTION_RESET):连接是重置。
我该如何解决这个问题?
也许您正在尝试上传大于4MB的文件,这是默认的最大允许大小。您可以尝试在web.config
:
<system.web>
<!-- Set the maximum upload file size to 100MB -->
<httpRuntime executionTimeout="240" maxRequestLength="102400" />
</system.web>
通常,我在我的项目中设置以下代码:
<system.web>
<httpRuntime maxRequestLength="102000" executionTimeout="110"/>
</system.web>
但是如果你扩展了
在machine中默认设置为4MB。但是你可以在你的web.config中重写它。例如,要将上传限制扩展到20MB,您可以这样做:
<system.web>
<httpRuntime executionTimeout="240" maxRequestLength="20480" />
</system.web