上传大文件
首先在web.config中添加:
<system.web>
<httpRuntime maxRequestLength="40960" executionTimeout="6000"/>
</system.web>
提交按钮的代码如下
protected void btnfileup_Click(object sender, EventArgs e)
{
try
{
FileUpload1.PostedFile.SaveAs(Server.MapPath("file/"+FileUpload1.FileName));
Page.ClientScript.RegisterStartupScript(Page.GetType(), "message", "<script language='javascript' defer>alert('上传成功!');</script>");
}
catch (Exception ex)
{
Response.Write(ex.Message.ToString());
Page.ClientScript.RegisterStartupScript(Page.GetType(), "message", "<script language='javascript' defer>alert('上传失败!');</script>");
}
}