Home > Backend Development > PHP Tutorial > Why Are My PHP Upload Limits Incorrectly Set Despite Using ini_set()?

Why Are My PHP Upload Limits Incorrectly Set Despite Using ini_set()?

Susan Sarandon
Release: 2024-12-05 09:53:14
Original
806 people have browsed it

Why Are My PHP Upload Limits Incorrectly Set Despite Using ini_set()?

Troubleshooting Error in Modifying Upload Limits Using PHP

In PHP 5.3.0, a developer encountered an unexpected behavior when attempting to adjust upload limits using ini_set(). Despite setting both upload_max_filesize and post_max_size to "10M" in php.ini, the code returned lower values: "2M" and "8M", respectively.

The developer initially suspected a bug but later discovered the issue stemmed from an incorrect usage of shorthand notation outside of php.ini. According to the official documentation, using shorthand notation (e.g., "10M" instead of "10485760") is not supported when modifying configuration values with ini_set().

Furthermore, the developer realized that upload_max_filesize cannot be modified dynamically using ini_set(). It is considered a PHP_INI_PERDIR configuration directive, meaning it can only be set in php.ini.

Resolution:
To resolve the issue, the developer adjusted the php.ini settings using standard numerical values (e.g., "10485760" for 10MB) and restarted the Apache server. This allowed the modified limits to take effect as expected.

The above is the detailed content of Why Are My PHP Upload Limits Incorrectly Set Despite Using ini_set()?. 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