douhang5493 2011-02-22 11:03
浏览 166
已采纳

PHP文件上传 - CGI上的内存处理

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条回答 默认 最新

  • dongzhao8233 2011-02-23 08:57
    关注

    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

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效
  • ¥15 悬赏!微信开发者工具报错,求帮改