GoAdmio

uploadmaxfilesize

Set the PHP upload_max_filesize limit in every php.ini file (default 64M), or read the current value, then reload PHP-FPM

On this page: Overview · Quick start · Syntax · Arguments · Output · Examples · Troubleshooting · Details · See also


Overview

upload_max_filesize is the largest single file PHP accepts in an upload. /go/uploadmaxfilesize changes it for every installed PHP version at once. It:

[!WARNING] Running the command with no arguments does not show the current value. It sets 64M. To read the value, use /go/uploadmaxfilesize return.


Quick start

# Allow uploads of up to 128 MB
/go/uploadmaxfilesize 128M

# Show the current value
/go/uploadmaxfilesize return

Syntax

# Set the value
/go/uploadmaxfilesize [value]

# Read the value
/go/uploadmaxfilesize return

Arguments

Argument Required Notes
value No A PHP size such as 64M, 128M, or 1G. Default: 64M.
return No Prints the current value instead of changing anything. Not case-sensitive.

An argument that starts with -- is treated as "no value", so the default 64M is used.

Value rules

Rule Detail
Format Use a plain number with a unit letter: K, M, or G.
Validation None. Any text is written to the files, and PHP may ignore a value it cannot read.
Several words Joined with spaces, so 128 M is written as 128 M, which is not valid. Write 128M.
Special characters Avoid /, &, and \. They break the edit.

Output

Situation Output
return The value from the first php.ini found, such as 64M. Empty if that file has no active line. The exit code is 1.
Value set Upload Max Filesize updated successfully.
Unsupported operating system Unknown operating system.

The success message is printed even when no php.ini file was found.


Examples

# Read the current value
/go/uploadmaxfilesize return
# Set 128 MB
/go/uploadmaxfilesize 128M
# Set 1 GB
/go/uploadmaxfilesize 1G
# Set the default (64M)
/go/uploadmaxfilesize
# Apply the change now instead of waiting for the scheduled reload
/go/reload
# Check every php.ini on a Debian or Ubuntu server
grep -r "^upload_max_filesize" /etc/php /etc/php.ini 2>/dev/null
# Check what the command-line PHP uses
php -r 'echo ini_get("upload_max_filesize"), "\n";'

Troubleshooting

Symptom Likely cause Fix
The limit did not change on the website The PHP-FPM reload runs about a minute later, or has not run. Wait a minute, or run reload or fpm.
The limit did not change with Apache mod_php Only PHP-FPM is reloaded. Run web or reload.
Reload never happened The at service is not installed or not running, and its errors are hidden. Install and start at, or reload by hand.
The value became 64M after running with no arguments No argument means "set the default". Use return to read, and pass a value to set.
return shows a different value than the site uses It reads only the first file found, which may be an older PHP version. Check the other files with the grep example above.
return prints nothing That file has no active upload_max_filesize line, so PHP uses its built-in default (2M). Set a value.
Message says "updated" but nothing changed No php.ini files were found. Check that PHP is installed and the paths in Details exist.
Unknown operating system. The server's OS is not one of the supported ones. Edit the php.ini files by hand.
Permission denied When a line has to be added, the write does not use sudo. Run as root.
Large uploads still fail Another limit is lower. Raise postmaxsize, maxexecutiontime, and memorylimit too. Check web server and proxy request size limits.
One site still has the old limit A per-site override, such as a PHP-FPM pool setting, .user.ini, or .htaccess, takes precedence over php.ini. Remove or update the override.

Details

What it does

flowchart TD
    A["/go/uploadmaxfilesize [value]"] --> B["Append the command to /var/log/go/uploadmaxfilesize.log"]
    B --> C["Read the OS and build the list of php.ini files"]
    C --> D{"OS supported?"}
    D -- "No" --> E["Print error and exit"]
    D -- "Yes" --> F["For each php.ini that exists"]
    F --> G{"Argument is return?"}
    G -- "Yes" --> H["Print the value and exit"]
    G -- "No" --> I{"Active line found?"}
    I -- "Yes" --> J["Replace the line"]
    I -- "No" --> K["Append a new line"]
    J --> L["Print success message"]
    K --> L
    L --> M["Schedule /go/fpm reload in 1 minute, unless one is already waiting"]

Files it changes

Files that do not exist are skipped.

Operating system Files
AlmaLinux, Rocky, CentOS, Red Hat, Fedora /etc/php.ini and /etc/opt/remi/<version>/php.ini for each version
Debian, Ubuntu /etc/php.ini and, for each version in /etc/php, the fpm, cli, and apache2 php.ini files

Steps in order

  1. Appends a timestamped line with the arguments to /var/log/go/uploadmaxfilesize.log.
  2. Reads the operating system and builds the list of php.ini files.
  3. For each file that exists:
    1. With return: prints the current value and stops. Only the first file is read.
    2. Otherwise uses the given value, or 64M if none was given.
    3. Replaces the existing active upload_max_filesize line, or appends a new one.
  4. Prints Upload Max Filesize updated successfully.
  5. Schedules /go/fpm reload for one minute later with at, unless a reload is already waiting.

Notes


See also

Command Description
postmaxsize Read or set PHP post_max_size across all php.ini files
maxfileuploads Read or set PHP max_file_uploads across all php.ini files
fileuploads Toggle PHP file_uploads across all php.ini files
maxexecutiontime Change the max execution time for all PHP versions
maxinputtime Read or set PHP max_input_time across all php.ini files
memorylimit Change the PHP memory limit for all PHP versions
reload Reload PHP-FPM and the active web server
fpm Restart all installed PHP-FPM versions on your server