.net上传大文件出现报错情况

lu18225857116 lu18225857116 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
前端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;
}
}
}
...全文

相关推荐

评论 5
收藏 已收藏
分享
返回顶部
lu18225857116
Web Services 12,164 成员 16,322 内容