PHP post_max_size local value overridden by master value on Plesk / IIS?

Nick Daugherty picture Nick Daugherty · Jul 30, 2012 · Viewed 7.2k times · Source

I'm running into a strange issue when uploading large files via PHP (through Drupal, though that's not the issue).

Basically, my file uploads fail due to post_max_size limits being reached, even though the local directive is set to 96M, and the file is 25M.

I've ensured everything else is correct, including max_input_time, max_upload_filesize, and the IIS FastCGI idle time. All these are plenty large and not the issue.

I am overriding the post_max_size directive through Plesk, which (I believe) stores the change in a registry value. Running phpinfo() on the domain shows the correct local and master values for all directives...96M local, 12M master.

The very strange thing is that when I change the master post_max_size in php.ini from 12M to 96M (and ensure the change has taken effect), it works normally! Changing the master value back to 12M (and keeping a local value of 96M) immediately causes uploads to fail again.

Is this a bug in PHP, or am I doing it wrong?

Answer

Nick Daugherty picture Nick Daugherty · Aug 1, 2012

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.