【问题标题】:ng-file-upload file size above 4.5mbng-file-upload 文件大小超过 4.5mb
【发布时间】:2017-05-02 20:37:55
【问题描述】:

我迷路了...只要字节数等于或小于 4193813 且文件名包含 11 个字符,ng-file-upload 就可以完美运行。如果上传大小增加一个字节,则标头会到达服务器而不是文件。

我的代码在客户端与 Danial 的示例相同。在后端,我正在运行 West-Wind.com Web Connection,这是一个 Microsoft Visual Foxpro Web 服务器。

查看 Fiddler,除了内容长度的字节数外,我的工作测试和损坏的测试看起来都是一样的。

我查看了 IIS7 请求过滤并看到设置了默认的 30mb 大小。还尝试将其设置为 16mg,但没有任何区别。

我想知道这是否是块大小限制和/或我没有正确处理标头中后端的某些内容...但这只是目前的猜测。

如果您有任何下一步的想法,我们将不胜感激。

...根据反馈意见, 这是我的代码的sn-p:(假设现在,多个文件不可能是下面的文件[0])

Upload.upload({
    url: 'postback794.wcsx',
    fields: oFileFlds,
    file: files[0]
}).then(function (response) {
    // the postback now includes valided uploads
    console.log('upload complete');
}, function (response) {
    //error
    console.log('Error status:' + response.status);
}, function (evt) {
    var progressPercentage = parseInt(100.0 * evt.loaded / evt.total);
    console.log('progress: ' + progressPercentage + '% ' + evt.config.file.name);
    _this.DisplayMessage = 'progress: ' + progressPercentage + '% ' + evt.config.file.name;
});

这是 HTML:

<button class="btn btn-primary pull-left"
     multiple
     ngf-select 
     accept="text/plain, image/*, application/pdf, application/msword"
     ng-model="VendorsController.AddlDocsFile"
     title="Click here to upload one or more documents.">
 Upload Document(s)
  <i class="fa fa-upload" style="font-size:14px; margin:3px;"></i>
</button>

在服务器上:

  DO WHILE !FEOF(lhFile)
     lcCommandLine = lcCommandLine + FREAD(lhFile,16484)
  ENDDO

我将假设 VFP 代码不熟悉,FREAD 是一个低级命令,它读取由句柄 (lhFile) 指定的文件的某些字节数(在本例中为 16484)。当到达文件结束标记时,FREAD 终止并且 DO 循环结束。然后 lcCommandLine 应该准备好解析整个命中。

在 ng-file-upload 工作的情况下,我可以看到所有的测试上传。当字节数高于断点时不是这种情况,lcCommandLine 值会在没有任何文件上传数据的情况下被切断 (HTTP_CONTENT_LENGTH=906)。

【问题讨论】:

标签: angularjs ng-file-upload westwind


【解决方案1】:

问题与安装 ASP.NET 时的 IIS 有关。

必须在 web.config 文件中进行两项设置。它们控制最大文件大小。设置如下:

(配置 system.webserver 中的第一个设置可以通过请求过滤下的 IIS UI 进行。)

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

这是第二个,也在 system.web 下的配置中:

<configuration>
<system.web>
    <httpRuntime maxRequestLength="500000000"  executionTimeout="120" />
</system.web>
<configuration>

感谢 Rick Strahl 为您指明去哪里寻找的方向......!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-11-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-11-09
    • 1970-01-01
    • 2017-08-16
    相关资源
    最近更新 更多