|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #52229 memory_limit vs post_max_size: misleading or incomplete documentation
Submitted: 2010-07-01 23:43 UTC Modified: 2010-10-25 21:12 UTC
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: gustavo at angulosolido dot pt Assigned:
Status: Not a bug Package: Documentation problem
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
 [2010-07-01 23:43 UTC] gustavo at angulosolido dot pt
It is stated here:

the memory_limit variable must be greater then post_max_size. This is repeated all over the Internet as can be seen by googling it.

However empirical evidence has shown otherwise. It is possible to upload files which are, say, 3 times larger than the memory_limit.

Similar reports also question that statement:

Another issue is that the relation between the allocation limit (memory_limit) and the actual size of the php-cgi process (when PHP is used with mod_fcdid or similar...) is not explained. It can be seen that a php-cgi process seems to start with a fixed memory size independent from memory_limit.

It would be very helpful if this could be clarified here:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2010-08-27 12:40 UTC] mycroes at gmail dot com
It is correct that uploading larger files is possible, however not in all ways. 
When using Apache with mod-php it's not possible to upload a file using stdin 
that's larger than the memory limit, probably because the script will get invoked 
only as soon as all the post data is available. Thus when using client side 
methods like plupload, it's impossible to upload files larger than memory_limit, 
which is quite annoying.
 [2010-10-25 21:12 UTC]
-Status: Open +Status: Bogus
 [2010-10-25 21:12 UTC]
As said by Ilia:
We no longer load the uploaded file entirely into memory. So I think it should be possible to upload a file that is > than the memory limit
 [2013-05-22 13:15 UTC] marc at ermshaus dot org
I was about to open a bug for the same issue when I found this report. states:

“If memory limit is enabled by your configure script, memory_limit also affects file uploading. Generally speaking, memory_limit should be larger than 

To me, the phrasing is misleading as it implies that file uploads (<input type="file">, multipart/form-data, $_FILES array) have to fit into memory_limit. That is 
probably not the case. It is my understanding that the second sentence from the quote only holds true for large application/x-www-form-urlencoded POST requests 
(without file uploads) while the first sentence is more or less incorrect/superfluous.

Other mentions of this issue:

PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Mon Jun 27 02:03:50 2022 UTC