使用 PHP 5.6 和 Apache 2.4 上传大文件时出错


Error uploading large files using PHP 5.6 & Apache 2.4

我已经在我的Windows开发工作站上与这个问题斗争了三天。我已经在 Apache 的 httpd.conf 和 PHP 的 php.ini 中进行了很多研究并更改了很多设置,并且没有取得任何明显的进展。问题是我能够上传最大 100KB 的图像文件,但在 100KB 到 300KB 之间,我开始超时。我希望能够上传最大 1MB 的图像。

在它超时之前的某个时候,我在 PHP 代码上放置了一个断点,所有 $_POST 变量都是空的。

总结:

  • 高达 100K -> 上传 好的,我在输出上看到"是"
  • 介于 100K 和 ~300K 之间 -> 我能够执行 PHP 代码,但所有 $_POST 变量都是空
  • 高于 ~300K -> 超时

这是代码:

<?php
   if( $_SERVER["REQUEST_METHOD"] == "POST" )
   {
      if( $_FILES["fileToUpload"]["error"] == UPLOAD_ERR_OK )
      {
         echo "Yes";
      }
   }
?>
<!DOCTYPE html>
<html>
<body>
<form action="TestFileUpload.php" method="post" enctype="multipart/form-data">
    <input type="file" name="fileToUpload" id="fileToUpload">
    <br />
    <input type="submit" value="Upload Image" name="submit">
</form>
</body>
</html>

这是相关的 httpd.conf

LimitRequestBody 20000000

这是相关的 php.ini

max_execution_time = 1800
max_input_time = -1
post_max_size = 100M
upload_max_filesize = 100M
memory_limit = 1024M

这是Apache的访问权限.log

127.0.0.1 - - [14/Jan/2016:11:01:39 -0200] "GET /TestFileUpload.php HTTP/1.1" 200 280
127.0.0.1 - - [14/Jan/2016:11:02:10 -0200] "POST /TestFileUpload.php HTTP/1.1" 408 221

这是 Apache 的错误.log(我清除了它并重新启动服务器以获得干净的输出)

[Thu Jan 14 10:57:00.709518 2016] [ssl:warn] [pid 4972:tid 448] AH01873: Init: Session Cache is not configured [hint: SSLSessionCache]
[Thu Jan 14 10:57:00.738518 2016] [mpm_winnt:notice] [pid 4972:tid 448] AH00455: Apache/2.4.6 (Win32) OpenSSL/1.0.1e PHP/5.5.5 configured -- resuming normal operations
[Thu Jan 14 10:57:00.739518 2016] [mpm_winnt:notice] [pid 4972:tid 448] AH00456: Apache Lounge VC11 Server built: Jul 15 2013 20:13:45
[Thu Jan 14 10:57:00.739518 2016] [core:notice] [pid 4972:tid 448] AH00094: Command line: 'C:''Program Files''Apache Software Foundation''Apache24''bin''httpd.exe -d C:/Program Files/Apache Software Foundation/Apache24'
[Thu Jan 14 10:57:00.753518 2016] [mpm_winnt:notice] [pid 4972:tid 448] AH00418: Parent: Created child process 1952
[Thu Jan 14 10:57:02.548518 2016] [ssl:warn] [pid 1952:tid 396] AH01873: Init: Session Cache is not configured [hint: SSLSessionCache]
[Thu Jan 14 10:57:02.575518 2016] [mpm_winnt:notice] [pid 1952:tid 396] AH00354: Child: Starting 64 worker threads.

我没有在 Apache 中使用mod_security。

任何

想法我还能尝试什么,任何配置?

您是否查看过 httpd 配置文件的 fcgid 部分中的超时设置?

<IfModule mod_fcgid.c>
[settings]
</IfModule>

它可能是 FcgidBusyTimeout 设置。默认值为 100;增加这个可能会帮助你。尝试:

<IfModule mod_fcgid.c>
FcgidBusyTimeout 9999
</IfModule>