14

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?

Nikola K.
  • 7,093
  • 13
  • 31
  • 39
Reado
  • 1,412
  • 5
  • 21
  • 51
  • 3
    HTTP is really not the right choice of protocol for uploading a 2GB file. You should be using (S)FTP for this. – Will Vousden Jan 06 '11 at 10:57
  • 3
    Have you verified those are the variables in use? (ie, through `phpinfo()`) PHP never stops surprising me about which config file it is actually reading... (Also, HTTP is so not meant for this...) – Thanatos Jan 06 '11 at 10:58
  • 1
    Why are you wanting to use PHP for this instead of something like FTP or any number or other ways of uploading files – Earlz Jan 06 '11 at 10:58
  • Basically I'm using some software written in Adobe AIR to upload a file. AIR is sending the file to the PHP server which uploads and allocates the file to a record. Is there no way to achieve this in PHP? – Reado Jan 06 '11 at 11:02
  • @Thanatos: Yeah I can see the variables in phpinfo() and they are correct. If I set the limit to >10G, the error states the limit is a negative number instead. – Reado Jan 06 '11 at 11:06
  • You might wanna check http://stackoverflow.com/questions/4083100/php-uploading-large-files-fail – chris Jan 06 '11 at 11:09
  • Thanks chris. I know I have memory_limit disabled, but the server only has 1GB of RAM. Could this be an issue? – Reado Jan 06 '11 at 11:12
  • You might want to check your operating system limits on filesizes – Mark Baker Jan 06 '11 at 11:34
  • Ok. When PHP uploads a file does it upload it to the /tmp folder? The /tmp folder has been set to 1GB. Could this be the problem? – Reado Jan 06 '11 at 11:35
  • I've read the file size limit of CentOS x86 is 2GB. Does anyone know the file size limit of the x64 version and could this be the resolution? – Reado Jan 06 '11 at 12:23

6 Answers6

18

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

Community
  • 1
  • 1
Mobiler
  • 255
  • 3
  • 10
  • I've been hours trying to find out what could be the issue with a owncloud install for uploading big files, and this was the issue after all. – Ark74 Dec 22 '15 at 05:17
  • This answer just solved what I spent days trying to solve! I wish I could give this more upvotes – Eric F Oct 18 '19 at 15:56
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.

bronze man
  • 1,470
  • 2
  • 15
  • 28
3

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.

Peter O.
  • 32,158
  • 14
  • 82
  • 96
phliKtid
  • 66
  • 2
2

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

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

By doing this, PHP will not crash when trying to convert "5G" into a 32-bit integer and you will be able to upload files as big as you allow with the "post_max_size" variable.

Fueled
  • 8,776
  • 9
  • 29
  • 31
2

Maybe this can come from apache limitations on POST size:

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

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

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

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.

regilero
  • 29,806
  • 6
  • 60
  • 99
  • I tried the same operation on a 64-bit OS and had no problems whatsoever. Thanks for your help. – Reado Feb 13 '11 at 14:15
0

We've had the same problem: uploads stopped at 2GB.

Under SLES (SUSE Linux Enterprise Server) 11 SP 2, php53 was the problem.

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

and upgraded to that, we now can upload 5GB :-)