php.net |  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
Votes:1
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
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: gustavo at angulosolido dot pt
New email:
PHP Version: OS:

 

 [2010-07-01 23:43 UTC] gustavo at angulosolido dot pt
Description:
------------
It is stated here:

http://www.php.net/manual/en/ini.core.php#ini.post-max-size

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:

http://zendframework.com/issues/browse/ZF-5703
http://www.php.net/manual/en/features.file-upload.php#78017

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:

http://www.php.net/manual/en/ini.core.php#ini.memory-limit
http://www.php.net/manual/en/ini.core.php#ini.post-max-size




Patches

Pull Requests

History

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] kalle@php.net
-Status: Open +Status: Bogus
 [2010-10-25 21:12 UTC] kalle@php.net
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.

http://www.php.net/manual/en/ini.core.php#ini.post-max-size states:

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

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:

- http://stackoverflow.com/questions/3651141/in-php-settings-should-memory-limit-upload-max-filesize
- http://stackoverflow.com/questions/5106871/relationship-between-phps-memory-limit-upload-max-filesize-and-post-max-filesi
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 28 17:01:27 2024 UTC