【问题标题】:Uploadify for ASP.NET app returns HTTP Error for large filesUploadify for ASP.NET 应用程序返回大文件的 HTTP 错误
【发布时间】:2013-04-24 09:37:15
【问题描述】:

我的 Uploadify 脚本适用于大多数小于 10 MB 的文件。但是一旦文件大小开始超过 40 MB,它将无法上传,只有“HTTP 错误”的错误消息。我尝试为 Uploadify 实现 onError 处理程序,但它没有给我任何详细信息,确切的错误是什么。变量返回“未定义”。我检查了我的 web.config 文件,文件大小限制设置为 50 MB,我的超时时间为 30 分钟,所以我不知道问题出在哪里。这是我的脚本:

$('#uploader').uploadify({
  'uploader': '/js/uploadify/uploadify.swf',
  'script': '/cms/common/uploadify/UploadHandler.ashx',
  'cancelImg': '/images/cancel_upload.png',
  'buttonImg': '/images/select_video_thumbnail_en-us.gif',
  'auto': true,
  'folder': '/Temp',
  'multi': false,
  'sizeLimit': 0,
  'displayData': 'percentage',
  'simUploadLimit': 1,
  'fileExt': '*.jpg;*.gif;*.png',
  'fileDesc': '*.jpg;*.gif;*.png',
  'buttonText': 'Select thumbnail...',
  'width': '120',
  'height': '24',
  'onComplete': function (e, queueId, fileObj, response, data)
  {
    return true;
  },
  'onError': function (a, b, c, d)
  {
    if (d.status == 404)
      alert('Could not find upload script.');
    else if (d.type === "HTTP")
      alert('error ' + d.type + ": " + d.status);
    else if (d.type === "File Size")
      alert(c.name + ' ' + d.type + ' Limit: ' + Math.round(d.sizeLimit / 1024) + 'KB');
    else
      alert('error ' + d.type + ": " + d.text);
  },
  'onCancel': function (e, queueId, fileObj, data)
  {

  }
});

【问题讨论】:

  • 您是否尝试过使用调试器查看发生了什么?我的第一个想法确实是 maxRequestLength 和 RequestTimeout。顺便说一句,30 分钟的超时使超时毫无用处,太长了! (你确定不是 30 秒吗?)
  • maxRequestLength = 50000, RequestTimeout= 30000。30 分钟不是不合理的。我尝试上传一个 40 MB 的文件,使用 DSL 连接花了将近 12 分钟。有些用户的速度可能真的很慢,所以 30 分钟是安全的。此外,您需要在系统大量使用时为系统提供时间。
  • 你是在本地运行还是在服务器上运行?
  • asp.net 应用程序在远程服务器上运行。该文件是从本地计算机上的浏览器上传的。

标签: asp.net uploadify


【解决方案1】:

我正在运行的 IIS7 的默认内部文件大小限制为 30 MB。将 maxRequestLength 设置为大于此值将无济于事。通过将以下内容添加到您的 web.config 文件可以解决问题:

<system.webServer>
        <security>
            <requestFiltering>
                <requestLimits maxAllowedContentLength="50000000"/>
            </requestFiltering>
        </security>
</system.webServer>

这也可以在 IIS7 中设置。有关更多详细信息,请参阅以下链接: IIS7 File Upload Size Limits Enabling Request Filtering In IIS 7

【讨论】:

    【解决方案2】:

    在您的上传功能中添加以下标签。

    'sizeLimit': '10045728'
    

    它会为你工作。大小限制是您的文件大小限制。它以 KB 为单位。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-11-21
      • 2011-06-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多