Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When uploading a very large file in PHP, how much RAM is required on the server?

Tags:

php

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

memory_limit must > post_max_size . Then if user upload a file 500MB then how much total RAM use ?

does it use >500MB ?

like image 240
meotimdihia Avatar asked May 08 '11 08:05

meotimdihia


1 Answers

No, memory_limit need not be greater than post_max_size.

PHP has different POST readers and handlers depending on the content type of the request. In case of "multipart/form-data" (what is used for sending files), rfc1867_post_handler acts as a mixed reader/handler. It populates both $_POST and $_FILES. What goes into $_POST counts towards the memory limit, what goes into $_FILES also counts.

However, $_FILES has just meta-data about the files, not the files themselves. Those are just written into the disk and hence don't count towards the memory limit.

like image 179
tyronegcarter Avatar answered Oct 17 '22 06:10

tyronegcarter