2013-04-24 44 views
4

我的Uploadify脚本适用于大多数小于10 MB的文件。但是,一旦文件大小开始超过40 MB,它将无法上传,只有一个错误消息“HTTP错误”。我试着为Uploadify实现onError处理程序,但它并没有给我提供任何具体的错误信息。该变量返回为“未定义”。我检查了我的web.config文件,并将文件大小限制设置为50 MB,并且我有30分钟的超时时间,所以我无法解决问题。这是我的脚本:Uploadify for ASP.NET应用程序为大文件返回HTTP错误

$('#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) 
    { 

    } 
}); 
+0

您是否尝试过使用调试器来查看发生了什么?我的第一个想法确实是maxRequestLength和RequestTimeout。顺便说一下,30分钟的超时会使超时无用,这太长了! (你确定它不是30秒?) – 2013-04-24 09:39:50

+0

maxRequestLength = 50000,RequestTimeout = 30000. 30分钟不是不合理的。我尝试上传一个40 MB的文件,并花了将近12分钟使用DSL连接。有些用户的速度可能真的很慢,所以30分钟的时间就是安全的。另外,当系统使用频繁时,您需要包含系统时间。 – AndroidDev 2013-04-24 09:42:11

+0

你是在本地运行还是在服务器上运行? – Serberuss 2013-04-24 09:43:46

回答

0

在您的uploadify函数中添加以下标记。

'sizeLimit': '10045728' 

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

3

我正在运行的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

相关问题