• <small id='qJSCw'></small><noframes id='qJSCw'>

    1. <tfoot id='qJSCw'></tfoot>
      <i id='qJSCw'><tr id='qJSCw'><dt id='qJSCw'><q id='qJSCw'><span id='qJSCw'><b id='qJSCw'><form id='qJSCw'><ins id='qJSCw'></ins><ul id='qJSCw'></ul><sub id='qJSCw'></sub></form><legend id='qJSCw'></legend><bdo id='qJSCw'><pre id='qJSCw'><center id='qJSCw'></center></pre></bdo></b><th id='qJSCw'></th></span></q></dt></tr></i><div id='qJSCw'><tfoot id='qJSCw'></tfoot><dl id='qJSCw'><fieldset id='qJSCw'></fieldset></dl></div>

      1. <legend id='qJSCw'><style id='qJSCw'><dir id='qJSCw'><q id='qJSCw'></q></dir></style></legend>
          <bdo id='qJSCw'></bdo><ul id='qJSCw'></ul>

      2. PHP 上传 - 500 内部服务器错误

        时间:2023-12-01

        1. <small id='XUjsu'></small><noframes id='XUjsu'>

          <legend id='XUjsu'><style id='XUjsu'><dir id='XUjsu'><q id='XUjsu'></q></dir></style></legend>
            <bdo id='XUjsu'></bdo><ul id='XUjsu'></ul>

                <tfoot id='XUjsu'></tfoot>
                  <tbody id='XUjsu'></tbody>
                <i id='XUjsu'><tr id='XUjsu'><dt id='XUjsu'><q id='XUjsu'><span id='XUjsu'><b id='XUjsu'><form id='XUjsu'><ins id='XUjsu'></ins><ul id='XUjsu'></ul><sub id='XUjsu'></sub></form><legend id='XUjsu'></legend><bdo id='XUjsu'><pre id='XUjsu'><center id='XUjsu'></center></pre></bdo></b><th id='XUjsu'></th></span></q></dt></tr></i><div id='XUjsu'><tfoot id='XUjsu'></tfoot><dl id='XUjsu'><fieldset id='XUjsu'></fieldset></dl></div>
                • 本文介绍了PHP 上传 - 500 内部服务器错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  The Issue

                  When uploading files of around 8MB or over, I recieve a 500 Internal Server Error.

                  1. All PHP settings in php.ini are correct
                  2. maxAllowedContentLength has been set in the web.config

                  Server Info

                  As one can probably tell from the maxAllowedContentLength, I am running IIS 7.5, with FastCGI and PHP 5.3.17

                  Additional Info

                  I have tried so many different things to get this working but simply cannot find the issue.

                  However, I have found the following bits of info that may help figure out the root of this problem:

                  1. When uploading files (larger ones) using the Media Wiki that I have on the server, I receive the same error, this goes to show that it is not an error in my code.
                  2. Most importantly - I managed to upload an 18MB file in the Plesk File Manager, this obviously means that Plesk was able to get around this config issue. I have tried to copy all of the Plesk Control Panel settings over to this domain in IIS but this does not seem to work.
                  3. The error is being returned before the script is executed, as I have tried writing exit; at the top to try to get a blank screen, but this is ignored and the 500 error is returned.

                  I think that the issue lies within the configure command part of the PHP configuration, because when I change the handler mapping of the .php files to use the Plesk php-cgi.exe instead of the usual one, I do not get the 500 Internal Error. Having said that, I cannot leave it on this PHP version as it is Plesk's own exe and there are other configuration issues.

                  The reason why I think it may be to do with the configure command, is simply because this differs hugely from one phpinfo() to the other.

                  If you have any ideas or suggestions, please post them. I have tried everything to my knowledge and cannot seem to fix this. If only it was Linux...

                  Thanks in advance

                  UPDATE 1

                  Forgot to add, there are no errors being returned in the PHP error log. As for IIS errors, I do not know where to look

                  UPDATE 2

                  This is what I have placed in my web.config file:

                  <security>
                      <requestFiltering>
                          <requestLimits maxAllowedContentLength="2147483647" /> 
                      </requestFiltering>
                  </security>
                  

                  UPDATE 3

                  With your help, we have managed to get the error displayed by IIS. This is what I am receiving:

                  PHP Warning: POST Content-Length of 12221448 bytes exceeds the limit of 8388608 bytes in Unknown on line 0

                  Is that to do with post_max_size?

                  UPDATE 4

                  PHP settings as follows (from phpinfo()):

                  post_max_size = 64M
                  memory_limit = 128M
                  max_file_uploads = 20
                  max_execution_time = 6000
                  upload_max_filesize = 64M
                  

                  UPDATE 5

                  Lastly, just in case anybody can spot any potential issues, Plesk is able to upload large files absolutely fine, so I assumed that their php-cgi.exe was compiled differently. When I read a phpinfo() of their configuration the configure command information was very different:

                  My configuration:

                  cscript /nologo configure.js "--enable-snapshot-build" "--disable-isapi" "--enable-debug-pack" "--without-mssql" "--without-pdo-mssql" "--without-pi3web" "--with-pdo-oci=C:php-sdkoracleinstantclient10sdk,shared" "--with-oci8=C:php-sdkoracleinstantclient10sdk,shared" "--with-oci8-11g=C:php-sdkoracleinstantclient11sdk,shared" "--enable-object-out-dir=../obj/" "--enable-com-dotnet=shared" "--with-mcrypt=static" "--disable-static-analyze"

                  Plesk's Configuration:

                  cscript /nologo configure.js "--enable-debug-pack" "--enable-cli" "--enable-cgi" "--enable-isapi" "--enable-one-shot" "--enable-pdo" "--enable-intl" "--with-openssl=shared" "--with-pdo-odbc" "--with-iconv" "--with-xml" "--with-xsl" "--with-mysql" "--with-mysqlnd" "--with-mysqli" "--with-pdo-sqlite" "--with-pdo-mysql" "--with-curl=shared" "--enable-mbstring" "--enable-mbregex" "--with-imap=shared" "--enable-sockets" "--enable-shmop" "--enable-soap"

                  UPDATE (ANSWER) This is extremely weird as the phpinfo() info is saying one thing, but it is obviously being ignored, not sure why.

                  If I change the post_max_size in Plesk, for that particular domain/sub-domain, then nothing is changed (although it appears to have changed in the phpinfo()). However, if I actually change the post_max_value in the php.ini then this fixes the issue.

                  The reason why this is not a good way to fix this, is simply because when Plesk updates, the php.ini is overwritten as PHP is updated and resultantly the changes made to the php.ini are lost. Which means that everytime that Plesk updates I will need to make changes tot he php.ini. This is why Plesk offers the ability to change PHP settings without making changes to the php.ini.

                  Can anybody think of why PHP is ignoring the local value and reverting to the value in the php.ini, even though the php.ini states that the local value is different?

                  解决方案

                  If you look at the source code of PHP, you can see on the file php-5.4.8-srcmain fc1867.c line 706-709 this:

                  if (SG(post_max_size) > 0 && SG(request_info).content_length > SG(post_max_size)) {
                      sapi_module.sapi_error(E_WARNING, "POST Content-Length of %ld bytes exceeds the limit of %ld bytes", SG(request_info).content_length, SG(post_max_size));
                      return;
                  }
                  

                  Same is there also in file php-5.4.8-srcmainSAPI.c. So, the message PHP Warning: POST Content-Length of 12221448 bytes exceeds the limit of 8388608 bytes in Unknown on line 0 is about post_max_size setting. You have confirmed from using phpinfo() that you have this setting configured correctly, but it seems to be using the default value of 8M anyway.

                  As to why, see this thread:

                  As it turns out, on Windows, you can only set ini directives that are marked PHP_INI_USER per directory. Unfortunately, upload_max_filesize and post_max_size are both PHP_INI_PERDIR. From the PHP docs at http://php.net/manual/en/configuration.changes.php

                  The settings for the directory would be active for any script running from this directory or any subdirectory of it. The values under the key should have the name of the PHP configuration directive and the string value. PHP constants in the values are not parsed. However, only configuration values changeable in PHP_INI_USER can be set this way, PHP_INI_PERDIR values can not.

                  So even though Plesk has an interface to change those directives, and even though phpinfo() picks up on them, they do nothing to change the actual max upload sizes. Plesk should not allow you to change those on Windows, and phpinfo() should not report the change, but what can you do.

                  So, it's post_max_size, and it needs to be set on php.ini. Plesk setting simply will not work, even though phpinfo says otherwise. I also opened a bug entry on phpinfo behaviour as there didn't seem to be an entry for it.

                  这篇关于PHP 上传 - 500 内部服务器错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:PHP AJAX 文件上传 下一篇:使用 PHP SDK 在亚马逊 S3 上上传文件

                  相关文章

                  <small id='PjQWQ'></small><noframes id='PjQWQ'>

                    <legend id='PjQWQ'><style id='PjQWQ'><dir id='PjQWQ'><q id='PjQWQ'></q></dir></style></legend>

                      <bdo id='PjQWQ'></bdo><ul id='PjQWQ'></ul>

                    1. <tfoot id='PjQWQ'></tfoot>
                      <i id='PjQWQ'><tr id='PjQWQ'><dt id='PjQWQ'><q id='PjQWQ'><span id='PjQWQ'><b id='PjQWQ'><form id='PjQWQ'><ins id='PjQWQ'></ins><ul id='PjQWQ'></ul><sub id='PjQWQ'></sub></form><legend id='PjQWQ'></legend><bdo id='PjQWQ'><pre id='PjQWQ'><center id='PjQWQ'></center></pre></bdo></b><th id='PjQWQ'></th></span></q></dt></tr></i><div id='PjQWQ'><tfoot id='PjQWQ'></tfoot><dl id='PjQWQ'><fieldset id='PjQWQ'></fieldset></dl></div>