.net上传大文件出现报错情况
前端flex调用后台上传程序,小文件上传没事,大文件上传出错
后台上传程序如下代码:
public class UploadHandler : IHttpHandler
{
private string uploadFolderPic = "Upload/pic";
private string uploadFolderMp4 = "Upload/mp4";
private int maxPostSize = 200 * 1024 * 2024;//设置文件的大小问200M
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/plain";
string gcid = context.Request.QueryString["gcid"] == null ? "" : context.Request.QueryString["gcid"].ToString();
string type = context.Request.QueryString["type"] == null ? "" : context.Request.QueryString["type"].ToString();
//context.Response.Write("Hello World");
HttpFileCollection files = context.Request.Files;
if (files.Count > 0)
{
string path = "";
if (type == "pic")
path=context.Server.MapPath(uploadFolderPic);
else if (type == "mp4")
path = context.Server.MapPath(uploadFolderMp4);
HttpPostedFile file = files[0];
string folderPath=path+ "/" +gcid;
if (Directory.Exists(folderPath) == false)//如果不存在就创建file文件夹
{
Directory.CreateDirectory(folderPath);
}
if (file != null && file.ContentLength > 0)
{
string savePath = folderPath + "/" + context.Request.Form["fileName"];
file.SaveAs(savePath);
context.Response.Write("上传完成");
context.Response.End();
}
}
else
{
context.Response.Write("参数错误");
context.Response.End();
}
}
public bool IsReusable
{
get
{
return false;
}
}
}