Doc #52229 [Com]: memory_limit vs post_max_size: misleading or incomplete documentation

From: Date: Wed, 22 May 2013 13:15:49 +0000
Subject: Doc #52229 [Com]: memory_limit vs post_max_size: misleading or incomplete documentation
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-9866@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=52229&edit=1 ID: 52229 Comment by: marc at ermshaus dot org Reported by: gustavo at angulosolido dot pt Summary: memory_limit vs post_max_size: misleading or incomplete documentation Status: Not a bug Type: Documentation Problem Package: Documentation problem PHP Version: Irrelevant Block user comment: N Private report: N New Comment: 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 Previous Comments: ------------------------------------------------------------------------ [2010-10-25 21:12:21] 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 ------------------------------------------------------------------------ [2010-08-27 12:40:09] 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-07-01 23:43:33] 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 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=52229&edit=1

« previous php.doc.bugs (#9866) next »