这是我在服务器上传视频的代码
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
文件时,它会在网页上返回一条错误消息,这里是错误代码
输出:错误101(net :: ERR_CONNECTION_RESET):连接是 复位。
我该如何解决这个问题?
答案 0 :(得分:1)
也许您正在尝试上传大于4MB的文件,这是默认的最大值allowed size。您可以尝试在web.config
:
<system.web>
<!-- Set the maximum upload file size to 100MB -->
<httpRuntime executionTimeout="240" maxRequestLength="102400" />
</system.web>
答案 1 :(得分:1)
通常,我将下面的代码设置到我的项目中..
<system.web>
<httpRuntime maxRequestLength="102000" executionTimeout="110"/>
</system.web>
但如果你延长...
4MB默认值在machine.config中设置,但您可以在web.config中覆盖它。例如,要将上传限制扩展到20MB,您可以这样做:
<system.web>
<httpRuntime executionTimeout="240" maxRequestLength="20480" />
</system.web