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

lu18225857116 2016-03-15 09:51:44
前端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;
}
}
}
...全文
436 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
lu18225857116 2016-06-08
  • 打赏
  • 举报
回复
已经解决!!!!!!!!
bdmh 2016-03-15
  • 打赏
  • 举报
回复
你后台是不是限制了文件上传大小,另外如果不同系统允许的最大文件大小是有限制的,如果你上传的大于这个也不行
changjiangzhibin 2016-03-15
  • 打赏
  • 举报
回复
1、上传文件不能无限大 2、限制文件上传大小 3、其他途径实现上传 过大的文件
  • 打赏
  • 举报
回复
flex也是富客户端,还用传统的html+http上传大文件就不太合适了 可以试试wcf的二进制编码传输 http://www.cnblogs.com/zhijianliutang/archive/2011/11/28/2265989.html

12,162

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 Web Services
社区管理员
  • Web Services社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧