PHP: Overriding 'upload_max_filesize' Configuration
You are experiencing issues with setting 'upload_max_filesize' in PHP 5.3.0 using 'ini_set()'. This is likely due to a misunderstanding of PHP configuration settings and their scope.
Shorthand Notation Limitations
Outside of the 'php.ini' file, you cannot use the shorthand notation ('10M') to specify configuration values. This notation is only valid within 'php.ini'. In your case, 'ini_set('upload_max_filesize', '10M')' is interpreting '10M' as '10' in megabytes, resulting in the default 2MB limitation.
'upload_max_filesize' Setting
Additionally, 'upload_max_filesize' is marked as 'PHP_INI_PERDIR' in the PHP configuration settings list. This means that it cannot be overridden using 'ini_set()'. You must set it directly in the 'php.ini' file or modify the .htaccess file to override it for the specific directory.
Restarting Apache Server
After modifying the 'php.ini' file, you need to restart the Apache server for the changes to take effect. This is necessary because the PHP configuration settings are compiled into the Apache configuration on server startup.
Conclusion
To correctly modify 'upload_max_filesize', follow these steps:
The above is the detailed content of Why Can't I Override `upload_max_filesize` with `ini_set()` in PHP?. For more information, please follow other related articles on the PHP Chinese website!