There was a problem loading the comments.

PHP variable upload_max_filesize Local Value and Master Value are different

Support Portal  »  Knowledgebase  »  Viewing Article

  Print

 

The difference between the local value and the master value of upload_max_filesize in your PHP configuration usually occurs because:

  1. Local Value: This is the setting that applies to the current script or context (e.g., a particular virtual host, directory, or .htaccess file).
  2. Master Value: This is the default global server setting in the main php.ini file 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. The local value can be set by the developer via code or configuration files. The commonly used location set PHP variable in code are;

  1. Overriding value specified in .htaccess, httpd.conf, .user.ini or php.ini:
    • If a .htaccess file, httpd.conf, or a specific virtual host configuration overrides the global value from php.ini, the local value will differ.
  2. Runtime Specification in PHP Code:
    • A script may use ini_set() to change the upload_max_filesize at runtime for the current script.
  3. 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.
  4. Script configuration file:
    • Scripts like WordPress allow specification of ini_set()  based PHP variable values in configuration files like wp-config.php 

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:

  1. Check the Master Configuration in php.ini:

    • Locate your php.ini file. You can find its path using:

      <?php
      phpinfo(); ?>
       
    • Look for the upload_max_filesize directive and set it to the desired value. For example:
       
      upload_max_filesize = 20M
  2. Ensure No Overrides Exist in .htaccess:

    • If you are using Apache, check for .htaccess files 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.ini value.
  3. Check for Runtime Overrides:

    • Inspect your PHP scripts for any ini_set() calls that might alter the upload_max_filesize value during execution.
  4. Verify the Changes:

    • Re-run phpinfo() and confirm that both the local value and master value now match.

 

Notes:

  • Ensure the post_max_size value in php.ini is also large enough to handle the uploads. It should generally be larger than upload_max_filesize.
  • Ensure the memory_limit value is also large enough to handle the uploads.

Share via
Did you find this article useful?  

Related Articles


Comments

Add Comment

Replying to  


Self-Hosted Help Desk Software by SupportPal
© Indichosts.net