Home > Backend Development > PHP Tutorial > Why Doesn't `ini_set()` Change `upload_max_filesize`?

Why Doesn't `ini_set()` Change `upload_max_filesize`?

Patricia Arquette
Release: 2024-12-19 10:09:25
Original
521 people have browsed it

Why Doesn't `ini_set()` Change `upload_max_filesize`?

Changing upload_max_filesize in PHP

When attempting to modify the upload_max_filesize setting using the ini_set() function, a user encountered an unexpected result. Despite setting the value to '10M' in both their script and the php.ini configuration file, the ini_get('upload_max_filesize') call returned '2M'.

Upon restarting the Apache server, the issue resolved itself. However, to fully understand why the ini_set() call was not having the desired effect, it's important to note the following points:

  • Shorthand notation not supported outside of PHP.ini: The short form 'M' used in '10M' is only recognized within the PHP.ini configuration file. When setting configuration values dynamically, it's necessary to use the full value, such as '10 Megabytes'.
  • upload_max_filesize cannot be set by ini_set(): The upload_max_filesize directive is configured with the PHP_INI_PERDIR flag, indicating that it can only be set in the php.ini file. Therefore, attempting to modify it using ini_set() will not take effect.

The above is the detailed content of Why Doesn't `ini_set()` Change `upload_max_filesize`?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template