Uploading a file larger than 2 GB using PHP

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

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

However, in error_log, I found:

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

Can someone tell me why this will not work, please?

+8
post php file-upload
source share
6 answers

Perhaps this could be due to apache limits on POST size:

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

It seems that this 2Gb limit may be greater on 64-bit installations. And I'm not sure if setting 0 in this directory does not reach the limit of compilation. see examples that stream:

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

Then remember to also change max_input_time in PHP.

But you reach high limits :-) maybe you can try the rich client (flash? Js?) On the browser side, transfer in pieces or some FTP stuff, with progress indicators for the user.

+2
source share

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

Firstly, the code that converts post_max_size and others from ascii to integer saves the value to int, so converting "9G" and putting the result in this int will cause the 9G value to be larger than the 32-bit variable.

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 you need to edit the PHP code and compile it manually (make sure you compile it as 64-bit). here is a link to the list of differences:

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

Link to this php error message: http://bugs.php.net/bug.php?id=44522

The file above is the difference in 5.2.10 code, but I just made manual changes to 5.2.17 code, and I just downloaded one 3.4gb file via apache / php (which didn't work before the change).

ope which helps.

+3
source share

I had a similar problem, but my configuration was:

 post_max_size = 1.8G upload_max_filesize = 1.8G 

but I could not upload the 1.2 GB file. The error was the same:

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

I spent the whole day thinking where the hell is the β€œlimit 1073741824” coming from!

Decision

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

Change of value, for example. 1800M fixed it.

Pls guarantees apache server reboot with apache2 restart service command

+3
source share

As phliKtid mentioned, this is a limitation with the PHP framework. Save for editing source code, as indicated in the error report associated with phliKtid, there is a workaround that involves setting upload_max_filesize to 0 in php.ini.

 ; Maximum allowed size for uploaded files. ; http://php.net/upload-max-filesize upload_max_filesize = 0 

This way, PHP will not crash when trying to convert β€œ5G” to a 32-bit integer, and you will be able to upload files as much as you can using the variable β€œpost_max_size”.

+1
source share

I will 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 this file into memory, memory_limit is irrelevant.

+1
source share

We had the same problem: the download stopped at 2 GB.

There was a problem with php53 in SLES (SUSE Linux Enterprise Server) 11 Service Pack 2.

Then we added a new repository with php54: http://download.opensuse.org/repositories/server:/php/SLE_11_SP2/

and updated to this, now we can download 5 GB :-)

0
source share

Source: https://habr.com/ru/post/650741/


All Articles