KNOWLEDGEBASE · PHP ENVIRONMENT
PHP variable upload_max_filesize Local Value and Master Value are different
Last updated 2025-06-07
The difference between the local value and the master value of upload_max_filesize in your PHP configuration usually occurs because:
- Local Value: This is the setting that applies to the current script or context (e.g., a particular virtual host, directory, or .htaccess file).
- Master Value: This is the default global server setting in the main
php.inifile maintained by cPanel > Select a PHP version.
Why They Are Different
The Local Value of a PHP variable is controlled by the developer via script commands, while the Global Value is maintained through cPanel > Select a PHP version. Local values can be set by the developer via code or configuration files. The most commonly used locations to set PHP variables in code are:
- Overriding values can be specified in .htaccess, httpd.conf, .user.ini or php.ini:
- If an
.htaccessfile,httpd.conf, or a specific virtual host configuration specifies a value for the variable, and overrides the global value, the local value will differ.
- If an
- Runtime Specification in PHP Code:
- A script may use
ini_set()to change theupload_max_filesizeat runtime for the current script.
- A script may use
- Per-directory or per-user settings:
- PHP configurations can vary for different directories or users, especially in shared hosting environments.
- These are specified in directory-specific or user-specific .htaccess, .user.ini or php.ini files.
-
Script configuration file:
- Scripts like WordPress allow specification of
ini_set() basedPHP variable values in configuration files like wp-config.php
- Scripts like WordPress allow specification of
Fixing the Discrepancy
To align the local value and master value, you need to identify where the override is happening and make the necessary adjustments.
Steps to Fix:
-
Check the Master Configuration in
php.ini:- Locate your
php.inifile. You can find its path using: - Look for the
upload_max_filesizedirective and set it to the desired value. For example:
- Locate your
-
Ensure No Overrides Exist in .htaccess:
- If you are using Apache, check for
.htaccessfiles in the current directory or parent directories. - Look for directives like:
php_value upload_max_filesize 10M
- Remove or adjust them to match your
php.inivalue.
- If you are using Apache, check for
-
Check for Runtime Overrides:
- Inspect your PHP scripts for any
ini_set()calls that might alter theupload_max_filesizevalue during execution.
- Inspect your PHP scripts for any
-
Verify the Changes:
- Re-run
phpinfo()and confirm that both the local value and master value now match.
- Re-run
Notes:
- Ensure the
post_max_sizevalue inphp.iniis also large enough to handle the uploads. It should generally be larger thanupload_max_filesize. - Ensure the memory_limit value is also large enough to handle the uploads.
Tell us what has to stay up.
A short conversation with an engineer. No quote-bot, no callback queue. We'll tell you honestly if we're not the right fit.