ng-file-upload文件大小在4.5mb以上 [英] ng-file-upload file size above 4.5mb

查看:65
本文介绍了ng-file-upload文件大小在4.5mb以上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我迷路了...只要字节数等于或小于4193813(文件名为11个字符),ng-file-upload就能完美工作.如果上载大小增加了一个字节,则标头会将其发送到服务器,而不是文件.

I'm at a lost... ng-file-upload works perfectly so long as the byte count is equal to or less than 4193813 with an 11 character filename. If the upload size increases by one byte, the header makes it to the server but not the file.

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

My code is identical on the client side to Danial's sample. On the backend, I'm running West-Wind.com Web Connection, a Microsoft Visual Foxpro web server.

使用Fiddler,除了内容长度的字节数外,我的工作测试和损坏的测试看起来都相同.

Looking with Fiddler, both my working and broken tests look identical except for the byte count of the content-length.

我查看了IIS7请求过滤,并看到设置了默认的30mb.还尝试将其设置为16mg,这没有区别.

I looked at IIS7 Request Filtering and see the default 30mb size is set. Also tried setting it to 16mg and it made no difference.

我想知道这是否是一个块大小限制,并且/或者我没有正确处理标头后端中的某些内容……但这只是一个猜测.

I'm wondering if this is a chunk size restriction and/or I'm not handling something on the backend in the header correctly... but that is just a guess at this point.

任何想到下一步的想法将不胜感激.

Any thoughts where to turn next would be greatly appreciated.

...根据反馈意见,这是我的代码的一个片段:(假设现在,多个文件而不是下面的文件[0])

...based on feedback comment, here is a snippet of my code: (assuming for now, multiple files not possible files[0] below)

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应该准备好完整的匹配数据进行解析.

I'm going to assume VFP code is unfamiliar, the FREAD is a low level command that reads a file specified by a handle (lhFile) for some number of bytes (16484 in this case). When end of file marker is reached the FREAD terminates and the DO loop is ended. lcCommandLine should then have the entire hit ready to be parsed.

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

In the case of ng-file-upload working, I can see all of the test upload. Not the case when the byte count is above the breaking point, the lcCommandLine value is cut off without any of the file upload data (HTTP_CONTENT_LENGTH=906).

推荐答案

安装ASP.NET时,该问题与IIS有关.

Issue was related to IIS when ASP.NET is installed.

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

Two settings have to be made in the web.config file. They control the maximum file size. The settings are as follows:

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

(This first setting which is within configuration system.webserver can be made through the IIS UI under Request Filtering.)

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

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

This is the second one which is also in the configuration under system.web:

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

谢谢里克·斯特拉尔(Rick Strahl)为您寻找去往何处的指示!!

Thank you Rick Strahl for your directions of where to go looking...!

这篇关于ng-file-upload文件大小在4.5mb以上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆