GoAdmio

maxfileuploads

Read or set PHP max_file_uploads (the most files allowed in one upload request; default 100) across all php.ini files, then reload PHP-FPM a minute later

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


Overview

/go/maxfileuploads sets PHP's max_file_uploads (the maximum number of files a visitor can send in a single upload request) in the php.ini file of every installed PHP version at once. It:

PHP ignores files beyond the limit in a single request. The limit applies to the number of files, not their size. For size limits, see uploadmaxfilesize and postmaxsize.


Quick start

# Set the default (100 files per request) in every php.ini
/go/maxfileuploads

The new value is live about a minute later.


Syntax

/go/maxfileuploads [number]
/go/maxfileuploads return
Form Behavior
/go/maxfileuploads Sets max_file_uploads = 100 in every php.ini file.
/go/maxfileuploads <number> Sets that value in every php.ini file.
/go/maxfileuploads return Prints the current value and changes nothing. The word is not case-sensitive.

If the first argument starts with -- (for example --force), it is ignored and 100 is set.


Options

This command has no options. It takes one optional argument.

Argument Required Default Notes
<number> No 100 A whole number of files. Nothing checks the value (see Validation).
return No — Prints the current value instead of setting one.

Output

Outcome What you get
Value set Max File Uploads updated successfully.
return The number from the first php.ini found. Blank if that file has no max_file_uploads line.
Unsupported operating system Unknown operating system. Nothing is changed.

The success message is printed even if no php.ini file was found, so it does not prove that anything changed. Check with return.

The scheduled reload prints nothing. Every run is also recorded in /var/log/go/maxfileuploads.log.

[!NOTE] return ends with exit status 1, and return does not schedule a reload. In scripts, read the output instead of relying on the exit status.


Examples

# Use the default of 100 files
/go/maxfileuploads
# Allow up to 50 files per request
/go/maxfileuploads 50
# Show the current value
/go/maxfileuploads return
# Apply the change immediately instead of waiting for the scheduled reload
/go/maxfileuploads 50 && /go/fpm

Troubleshooting

Symptom Likely cause Fix
The old value still shows in phpinfo() right after the command The PHP-FPM reload is scheduled for one minute later. Wait a minute, or run fpm now.
The value is still old after several minutes The reload is scheduled with at. If at isn't installed or its service isn't running, the job fails silently. Install at and start its service, then run /go/fpm reload.
A site on Apache with mod_php still uses the old value The scheduled reload covers PHP-FPM only. Reload the web server, for example with web.
Uploads of many files still fail Another limit is reached: file size, total request size, or a web server request limit. Check uploadmaxfilesize, postmaxsize, and your web server's request size limit.
A site uses a different value max_file_uploads can also be set in server or PHP-FPM pool configuration, which overrides php.ini. Change it where it is set.
return prints nothing The first php.ini has no uncommented max_file_uploads line. Run /go/maxfileuploads <number> to add it.
return shows a different value than one version uses return reports only the first php.ini file found. Open the other versions' php.ini files to compare.
Unknown operating system. The operating system name in /usr/local/goadmio/linux/os.db isn't one the script knows. The script supports AlmaLinux, Rocky, CentOS, Red Hat, Fedora, Debian, and Ubuntu.
Permission denied The command was not run as root. Adding a missing line writes to the file without sudo. Run it as root.
PHP reports a syntax error in php.ini after a change A non-numeric value, or several words, was passed and written as is. Run /go/maxfileuploads <number> again with one number, or use checkphpini.
Success message, but no file changed No php.ini files exist at the expected paths. Check the paths in Files it changes.

Details

Files it changes

The script reads the operating system from /usr/local/goadmio/linux/os.db. Only files that exist are changed.

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

How a value is written

For each php.ini file:

Situation Result
An uncommented max_file_uploads = line exists Every such line is replaced with max_file_uploads = <value>.
The setting is missing, or only exists as a comment (;max_file_uploads = 20) A new max_file_uploads = <value> line is added at the end of the file.

If the file's last line has no trailing newline, the added line may be joined to it. Check the file if PHP reports an error after the change.

Validation

The command does not check the value. Everything after the command name is written as typed, so 50 100 or abc ends up in php.ini as is. Pass a single whole number.

The scheduled reload

After the files are changed, the command checks the queue of scheduled jobs (atq). If no /go/fpm reload job is already waiting, it schedules /go/fpm reload to run one minute later.

What it does not change


See also

Command Description
fileuploads Read or set PHP file_uploads across all php.ini files
uploadmaxfilesize Read or set PHP upload_max_filesize across all php.ini files
postmaxsize Read or set PHP post_max_size across all php.ini files
maxinputvars Read or set PHP max_input_vars across all php.ini files
maxexecutiontime Change the max execution time for all PHP versions
checkphpini Scan every php.ini on the server for startup errors and delete the line that causes each one
fpm Restart all installed PHP-FPM versions on your server