Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4791 pages
Next.js and React

WordPress rejects an image upload because PHP cannot move the file into the uploads folder

Your error

The uploaded file could not be moved to wp-content/uploads/2026/11.1 more line it can show

Fix it fast

Most common cause, 1 of 3

PHP's account cannot write the uploads folder

Hand ownership of uploads to the user that executes PHP, then set directories to 755 and files to 644.

Fix
sudo chown -R www-data:www-data wp-content/uploads
sudo find wp-content/uploads -type d -exec chmod 755 {} +
sudo find wp-content/uploads -type f -exec chmod 644 {} +
Did this fix it?
Full steps for this cause: check, fix, verify

Short answer

The uploaded file could not be moved to wp-content/uploads/2026/11 means WordPress received the upload but PHP's move_uploaded_file returned false for that folder. On WordPress 7.1 with PHP 8.3 or 8.4, check that the account PHP runs as can write the folder, that no old upload_path option or UPLOADS constant points elsewhere, and that open_basedir allows the path.

  • Applies to WordPress 7.1, PHP 8.3, PHP 8.4, WP-CLI 2.12, Ubuntu 24.04
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Which cause do you have?

Take the folder from the message and compare its owner and mode with the account PHP runs as. WordPress prints the path relative to the install folder; when the uploads folder lies outside it, the message shows only the folder's last name plus the year and month, as in uploads/2026/11.

Run this first
cd /var/www/example.com
ls -ld wp-content/uploads wp-content/uploads/$(date +%Y) wp-content/uploads/$(date +%Y)/$(date +%m)
ps -eo user,comm | grep -E 'php-fpm|apache2|httpd' | sort -u

Then find the line you see in this list and open its fix:

  1. 1PHP's account cannot write the uploads folderls shows the year or month folder owned by root or by another account, without write permission for the PHP user
  2. 2An old upload_path option or UPLOADS constant points somewhere elseThe folder in the message is not the wp-content/uploads you expect, often a path from the previous server after a migration
  3. 3open_basedir does not include the uploads folderOwner and mode are right, the move still fails, and open_basedir is set for this site

What does the error look like?

  • The uploaded file could not be moved to wp-content/uploads/2026/11.
  • The uploaded file could not be moved to uploads/2026/11.

Cause 1 of 3

PHP's account cannot write the uploads folder

You seels shows the year or month folder owned by root or by another account, without write permission for the PHP user

Check

The uploaded file could not be moved to with a correct path usually means the account PHP runs as may not write the target folder. The PHP manual says move_uploaded_file returns false, and issues a warning, when a valid upload cannot be moved; WordPress hides that warning and shows its own message. Folders created by root, for example by a restore or a WP-CLI run as root, are the usual case.

Check
ls -ld wp-content/uploads/2026/11
sudo -u www-data test -w wp-content/uploads/2026/11 && echo writable || echo NOT writable

Fix

Hand ownership of uploads to the user that executes PHP, then set directories to 755 and files to 644. The WordPress permissions guide prefers files owned by your own user with PHP running as that user; where PHP runs as www-data, hand it only the uploads folder. The guide also says no directory should ever get 777, upload folders included.

Fix
sudo chown -R www-data:www-data wp-content/uploads
sudo find wp-content/uploads -type d -exec chmod 755 {} +
sudo find wp-content/uploads -type f -exec chmod 644 {} +

Verify

The write test passes and an image upload in the Media Library succeeds.

Verify
sudo -u www-data test -w wp-content/uploads/$(date +%Y)/$(date +%m) && echo writable

Confirmed by php.net

Did this fix it?

Cause 2 of 3

An old upload_path option or UPLOADS constant points somewhere else

You seeThe folder in the message is not the wp-content/uploads you expect, often a path from the previous server after a migration

Check

The uploaded file could not be moved to an unexpected folder means WordPress computed its upload directory from a leftover setting. With upload_path empty or equal to wp-content/uploads it uses wp-content/uploads; any other relative value is joined to the install folder and an absolute one is used as it is. A defined UPLOADS constant overrides both, unless multisite file rewriting is on.

Check
wp option get upload_path
grep -n "UPLOADS" wp-config.php
wp eval 'echo wp_upload_dir()["path"], PHP_EOL;'

Fix

Set upload_path back to the value WordPress treats as the default and remove a define of UPLOADS from wp-config.php unless you added it on purpose. Then check the folder it now points at against the first cause.

Fix
wp option update upload_path wp-content/uploads
# wp-config.php: delete a leftover line such as
# define( 'UPLOADS', 'old-folder' );

Verify

wp_upload_dir now prints a path inside wp-content/uploads.

Verify
wp eval 'echo wp_upload_dir()["path"], PHP_EOL;'

Confirmed by raw.githubusercontent.com

Did this fix it?

Cause 3 of 3

open_basedir does not include the uploads folder

You seeOwner and mode are right, the move still fails, and open_basedir is set for this site

Check

The uploaded file could not be moved to a writable folder can come from open_basedir. The PHP manual says move_uploaded_file honours open_basedir for the destination path only, and open_basedir restricts PHP to the directory trees it lists, so a site moved to a new path or an uploads folder outside the listed trees is refused. The web PHP may use other settings than the command line.

Check
grep -rn "open_basedir" /etc/php/ 2>/dev/null
wp eval 'var_dump( ini_get( "open_basedir" ) );'

Fix

Add the site folder, or at least the uploads folder, to open_basedir, separating entries with a colon on Linux. List the system temporary folder as well, since PHP keeps the incoming file there first and its ini reference requires that folder to be inside open_basedir. Restart PHP-FPM afterwards.

Fix
; php.ini or the pool's php_admin_value
open_basedir = "/var/www/example.com:/tmp"

sudo systemctl restart php8.3-fpm

Verify

wp_upload_dir reports no error, and a test image uploads.

Verify
wp eval 'var_dump( wp_upload_dir()["error"] );'

Confirmed by php.net

Did this fix it?

How do I stop it coming back?

  • Run WP-CLI as the PHP user, for example sudo -u www-data wp, so folders it creates are never owned by root.
  • After every migration, read upload_path and grep wp-config.php for UPLOADS before the first upload.
  • When you tighten open_basedir, add the uploads folder and the temporary folder in the same change.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine on the same stack: Spotless Laundry, EZ Estimater.

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.