I am wondering how PHP handles personal files upload. I'v read personal files upload is going to be split in portions and will also be put together following the upload has finished. Can there be any verification of the fact? This helps to know the handling and configurations for any file upload. May be the handling of mod_php or CGI exactly the same? mod_php is much more tied along with Apache. CGI needs to read a stream after which do it's miracle.

How's the memory involved with this method.

Is correct?

  1. Apache handles HTTP request
  2. Apache calls PHP over CGI and streams data (pipe)
  3. PHP splits input in portions of the certain size not to achieve the memory limit
  4. Stream finish is located
  5. PHP assembles split files into one file and can remove the split files
  6. Details about file upload is going to be save into $_FILES

PHP does browse the file in portions however it does not write these to individual files after which recombine them, it keeps writing these to exactly the same temporary file the one you receive in $_FILES.

It is 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