fileuploads
Read or set PHP
file_uploadsacross all php.ini files
- Command:
/go/fileuploads - Category: PHP
- Required argument: None. With no argument it sets the value to
On. - Optional argument:
[value]orreturn - Output: A confirmation line, or the current value with
return - Last updated: 2026-11-19
On this page: Overview · Quick start · Syntax · Arguments · Output · Examples · Troubleshooting · Details · See also
Overview
/go/fileuploads changes the PHP setting file_uploads in every php.ini file on the server. This setting decides whether PHP accepts HTTP file uploads at all. It:
- finds every
php.inifor every installed PHP version (web, command line, and Apache) - sets
file_uploadsto the value you give, orOnif you give none - schedules a reload of PHP-FPM about one minute later so the change takes effect
PHP only reads file_uploads from php.ini. A site cannot change it with ini_set() or a .user.ini file, which is why this command changes it for the whole server.
[!WARNING] The change applies to every domain. Setting it to
Offstops file uploads on all sites, including uploads in the media library of a CMS.
Quick start
# Check the current value
/go/fileuploads return
# Turn uploads off
/go/fileuploads Off
# Turn uploads on
/go/fileuploads On
Syntax
/go/fileuploads [value]
/go/fileuploads return
| Form | Behavior |
|---|---|
/go/fileuploads |
Sets file_uploads = On in every php.ini. |
/go/fileuploads <value> |
Sets file_uploads = <value> in every php.ini. |
/go/fileuploads return |
Prints the value from the first php.ini found, then exits with code 1. |
The command does not toggle the setting. Running it with no argument always sets On.
Arguments
| Argument | Required | Default | Notes |
|---|---|---|---|
[value] |
No | On |
Use On or Off. The value is not validated, and if you pass several words they are joined with spaces. |
return |
No | — | Prints the current value. Not case-sensitive. |
The command has no --option flags.
Files changed
Only files that exist are changed.
| System | Files |
|---|---|
| AlmaLinux, Rocky, CentOS, Red Hat, Fedora | /etc/php.ini and /etc/opt/remi/<version>/php.ini for each installed version |
| Debian, Ubuntu | /etc/php.ini and, for each installed version, /etc/php/<version>/fpm/php.ini, /etc/php/<version>/cli/php.ini, and /etc/php/<version>/apache2/php.ini |
Output
| Outcome | What you get |
|---|---|
return |
The current value, such as On, from the first file found. Empty if that file has no file_uploads line. Exit code 1. |
| Value set | File Uploads updated successfully. |
| Unsupported operating system | Unknown operating system. |
The confirmation line is printed even if no php.ini was found or changed. The command doesn't list the files it edited.
Logging
Every run is appended to /var/log/go/fileuploads.log.
Examples
# Read the current value
/go/fileuploads return
# Turn file uploads off for the whole server
/go/fileuploads Off
# Turn them back on (same as running it with no argument)
/go/fileuploads On
# Check the result on a Debian or Ubuntu server
grep -H '^file_uploads' /etc/php/*/fpm/php.ini
# Check the result on an AlmaLinux, Rocky, or CentOS server
grep -H '^file_uploads' /etc/opt/remi/*/php.ini
Troubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
Uploads still fail with file_uploads = On |
Another limit is blocking them. | Check uploadmaxfilesize, postmaxsize, and maxfileuploads. |
| The change doesn't apply right away | The reload is scheduled for about a minute later with at. |
Wait, or run fpm with reload. Check that the atd service is running. |
| Sites using Apache's PHP module don't change | Only a PHP-FPM reload is scheduled. | Reload the web server with web. |
return prints an empty line |
The first php.ini found has no file_uploads line, so PHP uses its default (On). |
Set the value, or check the file by hand. |
return doesn't match what a site uses |
It reads only the first file found, usually not the one for the version in use. | Check the file for that version with grep. |
File Uploads updated successfully. but nothing changed |
No php.ini file was found. |
Check that PHP is installed. See Files changed. |
Permission denied when adding the line |
The command was not run as root. | Run it as root. |
An odd value, such as yes please, was written |
Several arguments were passed and joined together. | Pass exactly one value. |
The command failed with a value that contains / or & |
The value is inserted into a sed command. |
Use only On or Off. |
Exit code 1 after return |
By design. | Ignore it for return. |
Details
What it does
- Logs the call to
/var/log/go/fileuploads.logand reads the operating system name from/usr/local/goadmio/linux/os.db. - Builds the list of
php.inifiles for the operating system. Stops withUnknown operating system.for any other system. - For each file that exists:
- reads the first
file_uploadsline and takes its value - for
return, prints that value and stops - with no argument uses
On, otherwise uses all arguments as the value - replaces every
file_uploadsline withfile_uploads = <value>, or adds the line at the end if the file has none
- reads the first
- Prints
File Uploads updated successfully. - If no pending
atjob already containsfpm reload, schedules/go/fpm reloadone minute later.
Reload
Because of step 5, several runs within a minute cause only one reload. Command-line PHP picks up the change the next time it starts. PHP-FPM picks it up at the reload.
Notes for maintainers
| Issue | Why it matters | Suggested fix |
|---|---|---|
With no argument it sets On, but the index calls it a toggle |
Misleading. | Describe it as "Read or set", like its sibling commands. |
return reads only the first existing file and exits with 1 |
Misses other files that differ, and success looks like failure. | Print every file with its value, and exit 0. |
| The value is not validated | Any text is written to php.ini, and a value with / or & breaks the sed command or can inject sed commands. |
Accept only On, Off, 1, and 0, and quote them. |
The read pattern ^file_uploads*=* is loose |
It matches any line that starts with file_upload, and ignores leading spaces that the write pattern allows. |
Use ^[[:space:]]*file_uploads[[:space:]]*= in both places. |
| Inline comments end up in the value | A line such as file_uploads = On ; comment returns On comment. |
Cut the value at the first ;. |
echo ... >> $File and grep -q run without sudo |
Appending fails when the command isn't started as root. | Re-run through sudo at the top, like most other commands. |
sed replaces every matching line |
Duplicate directives are all rewritten. | Replace only the first match. |
| The success message always prints | A run that changed nothing still reports success. | Count the files changed, and print them. |
| No backup and no syntax check before editing | A bad value can leave PHP unable to start. | Keep a backup, and test with php -n -c <file> -v, or at least php-fpm -t. |
The Debian and Ubuntu branches are identical, and FileArray is built twice |
Duplicate code. | Merge the branches. |
cd /etc/opt/remi or cd /etc/php is not checked |
If the folder is missing, the loop runs over the wrong folder. | Stop if the folder doesn't exist. |
atq and at -c run without sudo |
When not root, only the caller's jobs are visible, so reloads can be scheduled twice. | Run them as root, or use a flag file. |
Only fpm reload is scheduled |
Apache's PHP module (apache2/php.ini) is changed but not reloaded. |
Also reload the web server when Apache's module is in use. |
| The same code probably exists in the sibling commands | Fixes must be made in many places. | Move the shared logic into one function. If it is copied, apply these fixes to each command. |
The commands with the same "Read or set PHP … across all php.ini files" description are allowurlfopen, allowurlinclude, displayerrors, displaystartuperrors, errorreporting, maxfileuploads, maxinputtime, maxinputvars, postmaxsize, sessioncookielifetime, sessiongcmaxlifetime, uploadmaxfilesize, and zliboutputcompression.
See also
| Command | Description |
|---|---|
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 |
maxfileuploads |
Read or set PHP max_file_uploads across all php.ini files |
fpm |
Restart all installed PHP-FPM versions on your server |
reload |
Reload PHP-FPM and the active web server |
checkphpini |
Scan every php.ini for startup errors and remove the offending line |
multiphp |
Manage PHP versions per domain |