Uploading a file larger than 2GB using PHP

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

However, in the error_log I found:

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?


Solution 1:

I had a similar problem, but my config was:

post_max_size = 1.8G
upload_max_filesize = 1.8G

and yet I could not upload a 1.2GB file. The error was very same:

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

I spent a day wondering where the heck was this "limit of 1073741824" coming from!

Solution:

Actually, the error was in the php.ini parser: It only understands INTEGER numbers, so essentially it was parsing 1.8G as 1G !!

Changing the value to e.g. 1800M fixed it.

Pls ensure to restart the apache server with the below command service apache2 restart

Solution 2:

I don't know about in 5.3.x, but in 5.2.x there are some int/long issues in the PHP code. even if you're on a 64-bit system and have a version of PHP compiled with 64-bit, there are several problems.

First, the code that converts post_max_size and others from ascii to integer stores the value in an int, so it converting "9G" and putting the result into this int will bork the value because 9G is a larger number than a 32-bit variable can hold.

But there are also several other areas of PHP code that are used with the Apache module, CGI, etc. that need to be changed from int to long.

So...for this to work, you need to edit the PHP code and compile it by hand (make sure you compile it as 64-bit). here's a link to a list of diffs:

http://www.archive.org/~tracey/downloads/patches/karmic-64bit-post-large-files.patch

Referenced from this php bug post: http://bugs.php.net/bug.php?id=44522

The file above is a diff on 5.2.10 code, but I just made the changes by hand to 5.2.17 code and i just uploaded a 3.4gb single file through apache/php (which hadn't worked before the change).

ope that helps.

Solution 3:

I figure out how to use http and php to upload a 10G file.

php.ini:

post_max_size = 0
upload_max_filesize = 0

It works in php 5.3.10.

if you do not load that file all into memory , memory_limit is unrelated.