Uploading a file larger than 2GB using PHP(使用 PHP 上传大于 2GB 的文件)

本文介绍了使用 PHP 上传大于 2GB 的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将大于 2GB 的文件上传到本地 PHP 5.3.4 服务器.我设置了以下服务器变量:

I'm trying to upload a file larger than 2GB to a local PHP 5.3.4 server. I've set the following server variables:

memory_limit = -1
post_max_size = 9G
upload_max_filesize = 5G

然而,在 error_log 中我发现:

However, in the error_log I found:

PHP 警告:2120909412 字节的 POST Content-Length 超出第 0 行未知中 1073741824 字节的限制

PHP Warning: POST Content-Length of 2120909412 bytes exceeds the limit of 1073741824 bytes in Unknown on line 0

谁能告诉我为什么这总是失败?

Can anyone tell me why this keeps failing please?

推荐答案

这可能来自 apache 对 POST 大小的限制:

Maybe this can come from apache limitations on POST size:

http://httpd.apache.org/docs/current/mod/core.html#limitrequestbody

在 64 位安装上,2Gb 的这个限制似乎可能更大.而且我不确定在这个指令中设置 0 不会达到编译限制.请参阅该线程的示例:

It seems this limitation on 2Gb can be greater on 64bits installations, maybe. And i'm not sure setting 0 in this directove does not reach the compilation limit. see for examples that thread:

http://ubuntuforums.org/archive/index.php/t-1385890.html

然后不要忘记更改 PHP 中的 max_input_time.

Then do not forget to alter as well the max_input_time in PHP.

但是您达到了很高的限制:-) 也许您可以在浏览器端尝试一个富客户端(flash?js?),以块或某种 FTP 方式进行传输,并为用户提供进度指示器.

But you are reaching high limits :-) maybe you could try a rich client (flash? js?) on the browser side, doing the transfer in chunks or some sort of FTP things, with progress indicators for the user.

这篇关于使用 PHP 上传大于 2GB 的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!