When uploading files of around 8MB or over, I recieve a 500 Internal Server Error.
php.ini
are correctYou could turn the limits to -1, that way, you won't ever have troubles about the size of the files. It is probably no the best solution as you are basically saying "if I don't see it, it doesn't exist", but believe, it's really reliable and will always work.
IIS will re-use the FastCGI processes. You will need to kill off any old processes to get php.ini to reload.
Edit the FastCGI module and edit 'monitor changes to file' and select the php.ini file. This will force the child processes to restart whenever you save an edit.
If you look at the source code of PHP, you can see on the file php-5.4.8-src\main\rfc1867.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-src\main\SAPI.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
andpost_max_size
are bothPHP_INI_PERDIR
. From the PHP docs at http://php.net/manual/en/configuration.changes.phpThe 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, andphpinfo()
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.
This is a fairly common error and is due to the fact that the size of data being uploaded does not match file size: even if you POST max size is not exceeded by the file size, it could be by the uploaded data size.
See this page in the PHP manual.
; Maximum size of POST data that PHP will accept.
post_max_size = 8M
Another source of troubles (for VERY large texts) is UTF8 encoding. You might find yourself with a "six megabytes" TEXTAREA that is actually 6 mega*characters*, and with international codepoints it might run to, say, 8.2 megabytes. Thus you get an apparently contradictory situation of "six megabytes data exceed the configured 8 megabytes limit".
You report two apparently contradictory facts:
PHP settings as follows (from phpinfo()):
post_max_size = 64M
and
PHP Warning: POST Content-Length of 12221448 bytes exceeds the limit of 8388608 bytes
It is clear from the PHPINFO that the limit for POST is 64M. Yet the error says that the limit is 8M (the default). So it seems to me that your code is talking to two different PHP implementations (Two different virtual hosts? A CGI version and a non-CGI version in the same host? Two different machines?)