PHP File upload - memory handling on CGI

拜拜、爱过 提交于 2019-12-20 04:24:40

问题


I'm wondering how PHP handles a file upload. I'v read a file upload will be split in chunks and will be assembled after the upload has finished. Is there any verification of this fact? This will help to understand the handling and settings for a file upload. Is the handling of mod_php or CGI the same? mod_php is more tied together with Apache. CGI has to read a stream and then do it's magic.

How is the memory involved in this process.

Is this correct?

  1. Apache handles HTTP request
  2. Apache calls PHP over CGI and streams data (pipe)
  3. PHP splits input in chunks of a certain size to not reach the memory limit
  4. Stream end is found
  5. PHP assembles split files into one file and will delete the split files
  6. Information about file upload will be save into $_FILES

回答1:


PHP does read the file in chunks but it doesn't write them to individual files and then recombine them, it keeps writing them to the same temporary file which is the one you get in $_FILES.

It's the same for mod_php and CGI.

Here's the responsible code: http://svn.php.net/viewvc/php/php-src/branches/PHP_5_3/main/rfc1867.c?revision=307583&view=markup#l1065



来源:https://stackoverflow.com/questions/5077252/php-file-upload-memory-handling-on-cgi

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!