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

用NeatUpload上传大文件到web服务器问题
用NeatUpload上传大文件,在本机上测试可以上传300M的文件,上G的文件没有测试。但我把网站发布到web服务器上后,在本机IE浏览器访问网站上传文件,小文件可以上传,但50M的文件上传就不成功了,很困惑。请高手指点!
Web.Config中配置
........
<configSections>
  <sectionGroup name="system.web">
  <section name="neatUpload" type="Brettle.Web.NeatUpload.ConfigSectionHandler,Brettle.Web.NeatUpload" allowLocation="true" />
  </sectionGroup>
  </configSections>
..........
<httpModules>
  <!--上传大文件-->
  <add name="UploadHttpModule" type="Brettle.Web.NeatUpload.UploadHttpModule,Brettle.Web.NeatUpload"/>
  </httpModules>
  <!--useHttpModule="true" 设为true时才能看到上传状态,默认是False-->
  <neatUpload useHttpModule="true" maxNormalRequestLength="1048576" maxRequestLength="1048576" defaultProvider="FilesystemUploadStorageProvider">
  <providers>
  <add name="FilesystemUploadStorageProvider" type="Brettle.Web.NeatUpload.FilesystemUploadStorageProvider, Brettle.Web.NeatUpload"/>
  </providers>
  </neatUpload>
  <httpRuntime maxRequestLength="1048576" executionTimeout="3600"/>
.............

------解决方案--------------------
检查路径
------解决方案--------------------
用httpmodel试试。在webconfig 再设置个 文件大小。
------解决方案--------------------
基于http的,很难持续上传大文件.这与基于本机测试不一样.
3600秒? session都早就失效了.

------解决方案--------------------
大文件上传最好基于FTP工具.

如果真要用http,需要重写http处理模块.这对网站的http连接资源占用很大.
------解决方案--------------------
另外,IIS也有限定上传文件的尺寸,不可能由用户随意上传超大文件的.
主要是下面两项

maxAllowedContentLength

MaxRequestEntityAllowed


------解决方案--------------------
是否可以使用文件流的方法存储??
C# code

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using System.IO;
using System.Collections;
public partial class _Default : System.Web.UI.Page 
{
    protected void Page_Load(object sender, EventArgs e)
    {
     
    }
    protected void btnupfile_Click(object sender, EventArgs e)
    {
        string filename = fu.Value;
        Response.Write("<script type=\"text/javascript\">var sinfo=document.getElementById(\"sinfo\"); ");
        FileStream fsInput = new FileStream(filename, FileMode.Open, FileAccess.Read);
        StreamReader srInput = new StreamReader(fsInput);
        ArrayList   arraylist = new ArrayList();
        string srline;
        while ((srline = srInput.ReadLine()) != null)
        {
            arraylist.Add(srline);
        }
        srInput.Close();                           //关闭文件,释放资源
        fsInput.Close();

        //文件写
        string upfilepath = Server.MapPath("photo/") + Guid.NewGuid() + System.IO.Path.GetExtension(filename);
        FileStream fsOutput = new FileStream(upfilepath, FileMode.Create, FileAccess.Write);
        StreamWriter swOutput = new StreamWriter(fsOutput);
        int fisize = fu.MaxLength;
        for (int i = 0; i < arraylist.Count; i++)
        {
            Response.Write(" var val; val=\"文件大小:"+fisize+"K;\"");
            Response.Write(" val +=\"已上传: " + i * 1024 + "K;\"");
            Response.Write("sinfo.innerHTML=val;");
            swOutput.WriteLi