PHP的memory_limit的,和的upload_max_filesize post_max_filesize的关系 [英] Relationship between php’s memory_limit, upload_max_filesize and post_max_filesize
问题描述
底线:结果
我是否需要关注有关设置的 post_max_filesize
的>>的 memory_limit的
?
Bottom-line:
Do I need to be concerned about setting post_max_filesize
>> memory_limit
?
详情:结果
<一href=\"http://stackoverflow.com/questions/3651141/in-php-settings-should-memory-limit-upload-max-filesize#answer-3651195\">This答案表明,上传的文件不需要适应PHP的memory_limit的范围内。该 PHP文档表明,整个帖子应该PHP的内存限制内适应。
Details:
This answer suggests that uploaded files do not need to fit within php’s memory_limit. The php docs suggest that the entire post should fit within php’s memory limit.
我发现令人惊讶的文档,我希望有人能细说。例如采取以下PHP CONFIGS:
I find the docs surprising and I’m hoping someone can elaborate. For example take the following php configs:
; config A
memory_limit = 50M
upload_max_filesize = 100M
post_max_filesize = 1000M
max_file_uploads = 10
和
; config B
memory_limit = 50M
upload_max_filesize = 10M
post_max_filesize = 1000M
max_file_uploads = 100
有了这些配置,我期望能够为:
- 上传10x100mb文件到服务器的 A 的
- 和100x10mb文件服务器的乙的
- 与上传到服务器上的10个文件中的任何一个工作的 A 的是一个问题(在50M包文件100MS ...)
- 与上传到服务器上的100个文件中的任何1个工作的乙的是好的(10; 50)。
- Working with any one of the 10 files uploaded to server A is a problem (100Ms of file in a 50M bag…).
- Working with any 1 of the 100 files uploaded to server B is okay (10 < 50).
这经验将带领我说,一般memory_limit应该比的 的upload_max_filesize
的大;相反,PHP 文档说:
This experience would lead me to say that "generally the memory_limit should be larger than the upload_max_filesize
"; instead, the php docs say:
通常说,memory_limit应该比的 的post_max_size
的
generally speaking, memory_limit should be larger than
post_max_size
.
为什么,如果不是发生了什么?
Why and what happens if it isn't?
在我的PHP code执行我看,没有证据表明所有发布文件都在内存中。这在我看来,我的一切是完全在磁盘上找到路径文件的$ _FILES数组。 PHP是持有在内存中的整个后在之前我反思环境的能力一定意义呢?我是否需要关注有关设置的 post_max_filesize
的>>的 memory_limit的
?
When my php code is executed I see no evidence that all of the posted files are in memory. It seems to me that all I’ve got is a $_FILES array of paths to files found exclusively on disk. Is php holding the whole post in memory at some point prior to my ability to introspect the environment? Do I need to be concerned about setting post_max_filesize
>> memory_limit
?
旁白:结果
违反本手册的规则不会导致严重破服务器(W / PHP5.3的Apache2.2的debian 6)。
Aside:
Violating the manual's rule does not result in a grossly broken server (w/ php5.3 apache2.2 debian 6).
推荐答案
PHP将接受单项金额超过的upload_max_filesize
小,共同采取比<$ C $少上传的文件C>的post_max_size 字节。 PHP文档是错误的关于 memory_limit的
这并不需要持有该文件的内容发布。
PHP will accept uploaded files that are individually smaller than upload_max_filesize
and together take less than post_max_size
bytes. The PHP documentation is wrong with regard to memory_limit
which does not need to hold the file contents posted.
下面的配置可以使用两种模块的Apache2和CGI,并接受文件超过1G小。
The following configuration works with both Apache2 module and CGI, and accepts files smaller than 1G.
upload_max_filesize = 1G
post_max_size = 1G
memory_limit = 32M
这篇关于PHP的memory_limit的,和的upload_max_filesize post_max_filesize的关系的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!