日期:2014-05-17  浏览次数:20400 次

asp.net上传文件 过大
问题:我没有设置大小 上传了个9M的文件 就不行了。而且我调试的时候 都进不去 调试不了 为什么? //获取文件保存的路径
  string FilePath = Server.MapPath(".//") + "Files";
  //获取由客户端上载文件的控件集合
  HttpFileCollection HFC = Request.Files;
  for (int i = 0; i < HFC.Count; i++)
  {
  //对客户端已上载的单独文件的访问
  HttpPostedFile UserHPF = HFC[i];
  try
  {
  if (UserHPF.ContentLength > 0)
  {

  //调用GetAutoID方法获取上传文件自动编号
  int IntFieldID = CC.GetAutoID("fileID", "tb_files");
  //文件的真实名(格式:[文件编号]上传文件名)
  //用于实现上传多个相同文件时,原有文件不被覆盖
  string strFileTName = "[" + IntFieldID + "]" + System.IO.Path.GetFileName(UserHPF.FileName);

  string filename = System.IO.Path.GetFileName(UserHPF.FileName);//文件名字
  string exec = filename.Substring(filename.LastIndexOf(".") + 1); //后最名

  if (exec.ToLower() != "docx" && exec.ToLower() != "doc" && exec.ToLower() != "pdf")
  {
  ScriptManager.RegisterStartupScript(this, GetType(), "emptyError", "alert('只能上传(.docx .doc .pdf)三种类型!');", true);
  return;
  }
  else
   
  {
   
  Tb_file useradd = new Tb_file();
  useradd.FileID =int.Parse( IntFieldID.ToString());
  useradd.FileName = System.IO.Path.GetFileName(UserHPF.FileName).ToString();
  useradd.FileLoad = FilePath.ToString();
  useradd.FileTrueName = strFileTName.ToString();
  useradd.Areaname = buda.ToString();//省份
  useradd.Cityname = TextBox1.Text.ToString();//单位名称
  useradd.Tel = TextBox2.Text.ToString();//手机号码
  useradd.Uname = TextBox3.Text.ToString();//姓名
  useradd.Provincename = TextBox4.Text.ToString();//案例标题
  useradd.Uptime = DateTime.Now.ToLongDateString();//系统默认时间 DateTime.Now.AddDays(-1)前一天
  useradd.Unitname = ounameuser;//登陆人姓名
  useradd.Verifying = "审核中";
   
  Tb_fileManager.Instance.AddTb_file(useradd);
  //将上传的文件存放在指定的文件夹中
  UserHPF.SaveAs(FilePath + "//" + strFileTName);
  IntIsUF = 1;
  }
  }
  }
  catch
  {
  //文件上传失败,清空缓存中的上传控件集,重新加载上传页面
  if (Session["FilesControls"] != null)
  {
  Session.Remove("FilesControls");
  }
  Response.Write(CC.MessageBox("处理出错!", "FileUp.aspx"));
  return;
  }

  }
  //当文件上传成功或者没有上传文件,都需要清空缓存中的上传控件集,重新加载上传页面
  if (Session["FilesControls"] != null)
  {