使用 jQuery-File-Upload、Apache 和 PHP 上传 4GB HTTP 文件 [英] 4GB HTTP File Uploads Using jQuery-File-Upload, Apache and PHP

查看:33
本文介绍了使用 jQuery-File-Upload、Apache 和 PHP 上传 4GB HTTP 文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个问题似乎与臭名昭著的 2GB 限制直接相关,我不确定它是否是 32 位 PHP 问题.我已经看到与 HTTP 相关的评论不是为如此大的文件设计的.但是,在决定对迄今为止已证明有效的方法进行任何根本性改变之前,我宁愿穷尽这个方向.正如标题所示,我需要上传 > 2GB 的文件,迄今为止最大的 3.8GB.我有一个使用 jQuery-file-upload 构建的表单,在这些大文件开始之前,它在发送任何文件(全部小于 <2GB)时没有问题.3.8GB 的​​文件从 File-Upload 上传可能需要 5 分钟,进度条完成到 100%.但是上传后报告的错误是类型1,表明已违反文件大小限制.

This problem seems directly related to the infamous 2GB limit and I'm not sure at this atge if its a 32bit PHP issue. I've seen the comments related to HTTP not being designed for such large files. However, I would rather exhaust this direction before deciding on any fundamental change to what has been proven to work so far. As the title suggest I need to upload >2GB files, largest so far 3.8GB. I have a form built using jQuery-file-upload which has had no problems sending any files (all less <2GB) until these large ones started. The 3.8GB one takes maybe 5 minutes to upload from File-Upload and the progress bar completes to 100%. However the reported error after upload is a type 1 which suggests the file size limit has been breached.

如果我在上传期间监控服务器上的磁盘使用情况,它将具有以下示例属性:上传前磁盘使用率为 30%,随着上传继续,此使用率增加,31%,32%....45%,46% 等.然而,在 2GB 点左右,磁盘使用率回落到 30%,而客户端/浏览器文件上传仍在继续.当服务器磁盘使用量停止增加时,客户端可能仅达到上传的 60%.然而,客户端仍然继续 100%,但没有被服务器接受,因为磁盘状态永远不会降低 30%.

If I monitor the disk usage on the server during upload it will have the following sample properties: Before upload the disk is 30% used, as the upload continues this usage increases, 31%,32%....45%,46%etc. However at around the 2GB point the disk usage drops back to 30% while the client/browser File-Upload continues. When the servers disk usage stops increasing the client may only be at 60% of the upload. Yet the client still continues to 100% but isn't being accepted by the server as the disk status never moves off 30%.

我正在使用 Apache/2.2.22 (Ubuntu) 和 PHP 版本 5.3.10-1ubuntu3.2 运行 64 位 Ubuntu(最新)经过许多天断断续续地寻找解决方案后,在更改了这么多设置后,我仍然无法上传 3.8GB 的​​文件.我将在下面列出这些更改,但在此阶段,我认为这可能是 32 位 PHP 问题,因此如果有人可以提出值得关注的链接或值得尝试的解决方案,我将不胜感激.

I'm running 64Bit Ubuntu (latest) with Apache/2.2.22 (Ubuntu) and PHP Version 5.3.10-1ubuntu3.2 After many days on and off searching for a solution I still cannot get the 3.8GB file to upload after changing so many settings. I'll list the sort of changes below but at this stage I think it may be a 32bit PHP issue so if anyone can suggest a link worth following or solution worth trying I'd appreciate it.

在 Apache2 中,我设置了以下内容:

In Apache2 I've set the following:

- apache2.conf I've set Timeout to 900
- httpd.conf I've set LimitRequestBody to 0
- .htaccess in the file upload directory I've set:
    - LimitRequestBody to 4939212390
    - php_value upload_max_filesize 4831838208
    - php_value post_max_size 4939212390

在 php.ini 中我设置了以下内容:

In php.ini I've set the following:

- UPLOAD_MAX_FILESIZE 4831838208
- POST_MAX_SIZE 4939212390
- max_execution_time 120
- max_input_time 60
- memory_limit 128M

如果我在服务器上运行以下命令,PHP 似乎没有 32 位问题,但我现在不确定.

If I run the following on the server it would seem the PHP does not have a 32bit issue but I'm not sure at this stage.

php -r "echo PHP_INT_MAX;"
9223372036854775807

正如我所提到的,任何想法都将不胜感激.

As I mentioned any ideas would be greatly appreciated.

更新:

已经解决了这个问题,感谢@BogdanBurim 建议回归基础的方法:

Have solved this issue, so thanks to @BogdanBurim for suggesting the back to basics approach:

我已经使用以下设置通过 HTTP 上传了一个 3.8 GB 的文件:

I have managed to upload a 3.8 GB file over HTTP with the following settings:

在 Apache2 中,我设置了以下内容:

In Apache2 I've set the following:

- apache2.conf I've set Timeout to 900
- httpd.conf I've set LimitRequestBody to 0
- .htaccess in the file upload directory I've set:
    - LimitRequestBody to 0
    - php_value upload_max_filesize 0
    - php_value post_max_size 4939212390
- .htaccess in the php temp directory (in my case its /tmp/) I've set:
    - LimitRequestBody to 0
    - php_value upload_max_filesize 0
    - php_value post_max_size 4939212390

在 php.ini 中我设置了以下内容:

In php.ini I've set the following:

- UPLOAD_MAX_FILESIZE 0
- POST_MAX_SIZE 4939212390
- max_execution_time 120
- max_input_time 60
- memory_limit 128M

此解决方案唯一的另一个重要部分是必须从上传表单中删除 MAX_FILE_SIZE、HTML:

The only other important part of this solution was having to remove the MAX_FILE_SIZE, HTML from the upload form:

<input type="hidden" name="MAX_FILE_SIZE" value="4939212390" />

这个设置不断导致 PHP 类型 2 错误,因此 php 无法处理设置的大于 32 位的整数.删除它会导致 PHP 类型 1 错误,直到我将 UPLOAD_MAX_FILESIZE 随处更改为 0,嘿,它现在可以工作了!!!!

Having this set continually caused a PHP type 2 error, so php couldn't handle the greater than 32bit integer that is set. Removing it caused PHP type 1 errors until I changed the UPLOAD_MAX_FILESIZE to 0 everywhere and hey presto it now works!!!!

http://php.net/manual/en/features.file-upload.errors.php

推荐答案

已经解决了这个问题,感谢@BogdanBurim 建议回归基础的方法:

Have solved this issue, so thanks to @BogdanBurim for suggesting the back to basics approach:

我已经使用以下设置通过 HTTP 上传了一个 3.8 GB 的文件:

I have managed to upload a 3.8 GB file over HTTP with the following settings:

在 Apache2 中,我设置了以下内容:

In Apache2 I've set the following:

- apache2.conf I've set Timeout to 900
- httpd.conf I've set LimitRequestBody to 0
- .htaccess in the file upload directory I've set:
    - LimitRequestBody to 0
    - php_value upload_max_filesize 0
    - php_value post_max_size 4939212390
- .htaccess in the php temp directory (in my case its /tmp/) I've set:
    - LimitRequestBody to 0
    - php_value upload_max_filesize 0
    - php_value post_max_size 4939212390

在 php.ini 中我设置了以下内容:

In php.ini I've set the following:

- UPLOAD_MAX_FILESIZE 0
- POST_MAX_SIZE 4939212390
- max_execution_time 120
- max_input_time 60
- memory_limit 128M

此解决方案唯一的另一个重要部分是必须从上传表单中删除 MAX_FILE_SIZE、HTML:

The only other important part of this solution was having to remove the MAX_FILE_SIZE, HTML from the upload form:

<input type="hidden" name="MAX_FILE_SIZE" value="4939212390" />

这个设置不断导致 PHP 类型 2 错误,因此 php 无法处理设置的大于 32 位的整数.删除它会导致 PHP 类型 1 错误,直到我将 UPLOAD_MAX_FILESIZE 随处更改为 0,嘿,它现在可以工作了!!!!

Having this set continually caused a PHP type 2 error, so php couldn't handle the greater than 32bit integer that is set. Removing it caused PHP type 1 errors until I changed the UPLOAD_MAX_FILESIZE to 0 everywhere and hey presto it now works!!!!

http://php.net/manual/en/features.file-upload.errors.php

这篇关于使用 jQuery-File-Upload、Apache 和 PHP 上传 4GB HTTP 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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