You manage a WordPress site on a cPanel server, and the media library answers an upload with “The uploaded file could not be moved to wp-content/uploads/2026/10.” instead of a thumbnail. The file did arrive: PHP saved it to a temporary folder, and WordPress failed only at the last step, moving it into this month’s folder under uploads. On cPanel that move runs as your account user, so the message means that user may not write in that folder right now. The usual causes are a folder owned by root after a migration or restore, a full disk or inode quota (an inode quota caps how many files the account may hold), or an upload path pointing somewhere else. The steps below find which one it is with a single command, fix it without a blanket chmod 777, and prove the fix with a real upload.
What you’ll accomplish
- Reproduce the failed write as the account user and get the real reason from the operating system in one line.
- Repair ownership and permissions on the uploads tree the cPanel-safe way, scoped to the account.
- Rule out a full disk or inode quota, a stale upload path, and a plugin that redirects uploads.
- Prove the fix with a browser upload and with WP-CLI.
Prerequisites
- A WordPress site on a cPanel server. The paths below do not change between cPanel & WHM versions.
- PHP served by PHP-FPM, LSAPI (LiteSpeed Server Application Programming Interface), suPHP, or CGI with suEXEC. The handler is the part of the web server that starts PHP and decides which user it runs as. PHP-FPM has been the default on new cPanel installs since version 76, and all four of these run each account’s PHP as that account’s user. The exception, DSO, is covered in step 3.
- A terminal. cPanel → Advanced → Terminal already runs as the account user. Root access (SSH or WHM) is needed only to change the owner of files that belong to another user; where a step needs it, it says so and tells you what to ask your host.
- WP-CLI, so you can ask WordPress questions from the shell instead of the dashboard (
wp --infoprints a version if it is installed). - Example values used throughout: account user
cpuser, document root/home/cpuser/public_html, failing folderwp-content/uploads/2026/10. Swap in your own.
How it works
An upload from the media library takes two separate writes. First the browser posts the file to wp-admin/async-upload.php and PHP saves the body into its temporary folder, usually /tmp. Then WordPress runs wp_handle_upload(). It asks wp_upload_dir() for this month’s destination, creates the year and month folders if they are missing, and finally calls PHP’s move_uploaded_file() to move the file into place.
Each stage has its own error message, so the wording tells you which one failed:
- “Missing a temporary folder” or “Failed to write file to disk” means the first write failed. That is a different problem, covered in Fix WordPress “Missing a temporary folder” upload errors.
- “Unable to create directory wp-content/uploads/2026/10. Is its parent directory writable by the server?” means the month folder could not be created. The parent folder is the problem.
- “The uploaded file could not be moved to wp-content/uploads/2026/10.” means the month folder exists, but the final move into it returned false. That is this article.
Two details of the WordPress code make this error harder than it needs to be. WordPress calls move_uploaded_file() behind the @ operator, which silences PHP warnings, so the PHP error log usually says nothing about the failure. That is why step 1 reproduces the write by hand instead of hunting through logs. And the path in the message is trimmed: when uploads live outside the WordPress install, the message shows only uploads/2026/10 without the wp-content/ prefix, a clue for step 6.
On cPanel, PHP runs as the account user, so the move succeeds only if that user may write in the month folder. Two things decide that: who owns the folder (its ownership) and what the owner, the group and everyone else may do with it (its permissions, shown as a mode such as 755). The diagram shows the shape of the problem: every folder on the path belongs to cpuser except the one the error names, which a migration or a root cron created as root.
Step-by-step
1. Reproduce the failed write as the account user. Turn the folder from the message into a full path and try to create a file in it as the user PHP runs as. From cPanel Terminal you already are that user:
touch /home/cpuser/public_html/wp-content/uploads/2026/10/.write-test && echo WRITE OK
From an SSH session as root, run the same test as the account user:
su -s /bin/bash -c 'touch /home/cpuser/public_html/wp-content/uploads/2026/10/.write-test && echo WRITE OK' cpuser
Example output, showing the four answers you can get:
WRITE OK
touch: cannot touch '/home/cpuser/public_html/wp-content/uploads/2026/10/.write-test': Permission denied
touch: cannot touch '/home/cpuser/public_html/wp-content/uploads/2026/10/.write-test': Disk quota exceeded
touch: cannot touch '/home/cpuser/public_html/wp-content/uploads/2026/10/.write-test': No such file or directory
Permission denied sends you to step 2. Disk quota exceeded sends you to step 5. No such file or directory means WordPress writes to a different path than the one you typed, so go to step 6. WRITE OK means the folder is fine for cpuser, so either PHP is not running as cpuser (step 3) or WordPress is writing somewhere else (steps 6 and 7). If the test file was created, remove it with rm /home/cpuser/public_html/wp-content/uploads/2026/10/.write-test.
2. Check the owner and mode of every folder on the path. stat prints the owner, the group and the permission mode for each folder, one line each:
cd /home/cpuser/public_html
stat -c '%U:%G %a %n' wp-content wp-content/uploads wp-content/uploads/2026 wp-content/uploads/2026/10
Example output:
cpuser:cpuser 755 wp-content
cpuser:cpuser 755 wp-content/uploads
cpuser:cpuser 755 wp-content/uploads/2026
root:root 755 wp-content/uploads/2026/10
Any line whose owner is not cpuser is your answer. Mode 755 lets the owner write and everyone else only read and enter, which is correct when the owner is right and useless when it is root. A mode such as 555 fails even with the right owner, because the owner’s write bit is missing. Root-owned folders appear after an rsync or tar run as root, a restore script, or a root cron job. Count how many files are affected:
find /home/cpuser/public_html/wp-content/uploads ! -user cpuser | wc -l
Example output:
2619
Anything above zero needs step 4. Zero with Permission denied in step 1 points at a missing write bit, which step 4 also repairs.
3. Confirm which user PHP runs as. The ownership fix only works if PHP really runs as cpuser. cPanel prints the handler for each installed PHP version:
/usr/local/cpanel/bin/rebuild_phpconf --current
Example output:
DEFAULT PHP: ea-php83
ea-php74 SAPI: cgi
ea-php81 SAPI: lsapi
ea-php82 SAPI: lsapi
ea-php83 SAPI: lsapi
fpm, lsapi, suphp and cgi (with suEXEC installed) all run PHP as the account user. If the version your site uses shows dso, PHP runs as Apache’s nobody user, and no amount of chown to cpuser will help. Switch the handler in WHM → Software → MultiPHP Manager → PHP Handlers, or ask your host which handler they use.
4. Restore ownership and permissions, scoped to the uploads tree. This needs root, because only root can take files away from another owner. Give the whole uploads tree back to the account, then set folders to 755 and files to 644:
chown -R cpuser:cpuser /home/cpuser/public_html/wp-content/uploads
find /home/cpuser/public_html/wp-content/uploads -type d -exec chmod 755 {} +
find /home/cpuser/public_html/wp-content/uploads -type f -exec chmod 644 {} +
find /home/cpuser/public_html/wp-content/uploads ! -user cpuser | wc -l
Example output:
0
Keep the chown on wp-content/uploads or wp-content, never on public_html or the home folder. cPanel normally keeps public_html itself as cpuser:nobody with mode 750 (the group is cpuser on servers that use mod_ruid2), and other folders under the home directory carry owners and modes that cPanel set on purpose. Resist chmod 777 too: it lets every other process on the server write into your uploads, and it hides the real cause, which returns with the next sync. If chown answers Operation not permitted, you are not root: send your host the stat output from step 2 and ask for exactly the four commands above.
Rerun step 1. WRITE OK means ownership was the cause; jump to validation.
5. Check the disk and inode quota. A full quota gives the same WordPress message, because the month folder exists but the kernel refuses the write. quota -s shows both the space and the file count for the account:
quota -s -u cpuser
Run quota -s without -u when you are the account user in cPanel Terminal. Example output:
Disk quotas for user cpuser (uid 1037):
Filesystem space quota limit grace files quota limit grace
/dev/sda3 10240M* 10240M 10240M 6days 118302 0 0
An asterisk after space means the account has hit its disk quota. The files column is the inode count. Each file and folder uses one inode, so a plan can run out of them while space is still left. Here the filesystem sets no inode limit (0), but CloudLinux servers can cap inodes per package. cPanel can show that cap in the Statistics sidebar as “File Usage” once your host enables it in WHM’s Tweak Settings. Free space in the usual places (wp-content/cache, old backup archives, mailboxes), or raise the limit in WHM → Account Functions → Quota Modification. Then rerun step 1.
6. Check where WordPress is actually writing. WordPress computes the destination from the upload_path option, the UPLOADS constant in wp-config.php, and any filter on upload_dir. After a migration between two accounts on the same server, an old absolute path often survives. Ask WordPress for its answer:
cd /home/cpuser/public_html
wp option get upload_path
wp config get UPLOADS
wp eval 'print_r(wp_upload_dir());'
Example output after a migration from the account oldshop:
/home/oldshop/public_html/wp-content/uploads
Error: The constant or variable 'UPLOADS' is not defined in the 'wp-config.php' file.
Array
(
[path] => /home/oldshop/public_html/wp-content/uploads/2026/10
[url] => https://example.com/wp-content/uploads/2026/10
[subdir] => /2026/10
[basedir] => /home/oldshop/public_html/wp-content/uploads
[baseurl] => https://example.com/wp-content/uploads
[error] =>
)
A healthy site prints an empty line for upload_path, the same UPLOADS error (not defined is the normal state), and a basedir under your own document root. Here the old account’s folder still exists and is readable, so WordPress found it and then failed to write into it. Point the site back at its own folder:
wp option update upload_path ""
wp option update upload_url_path ""
If wp config get UPLOADS printed a path instead of the error, remove it with wp config delete UPLOADS. If open_basedir is set for the account (a PHP directive that limits which folders scripts may touch, edited in WHM → Software → MultiPHP INI Editor), PHP cannot see the old account’s folder at all. You then usually get the “Unable to create directory” message instead, and the fix is identical.
7. Check plugin filters and multisite paths. A plugin can rewrite the destination through the upload_dir filter; offloading and membership plugins often do. Compare the path with and without plugins:
wp eval 'echo wp_upload_dir()["path"], PHP_EOL;'
wp eval 'echo wp_upload_dir()["path"], PHP_EOL;' --skip-plugins
Example output:
/home/cpuser/public_html/wp-content/uploads/private/2026/10
/home/cpuser/public_html/wp-content/uploads/2026/10
If the two lines differ, a plugin owns the first path, and that folder must exist and belong to cpuser. On a multisite network each site writes to wp-content/uploads/sites/<id>/, so check the failing site by its URL:
wp --url=shop.example.com eval 'echo wp_upload_dir()["path"], PHP_EOL;'
Example output:
/home/cpuser/public_html/wp-content/uploads/sites/3/2026/10
Run stat on whichever path these commands print. If it sits under wp-content/uploads, step 4 already repaired it.
Validate it works
- Browser. In the dashboard open Media → Add New Media File and upload a small PNG. It should appear in the grid with a thumbnail and no red notice.
- WP-CLI, as the account user. Copy any small JPEG to
/home/cpuser/test-upload.jpgwith the File Manager orscp, then import it. Run this from cPanel Terminal or throughsu -s /bin/bash -c '...' cpuser, never as root, or the new files will belong to root and recreate the problem you fixed a moment ago.
cd /home/cpuser/public_html
wp media import /home/cpuser/test-upload.jpg --title='Upload test after fix' --porcelain
ls -l wp-content/uploads/2026/10/test-upload*
Example output:
4917
-rw-r--r-- 1 cpuser cpuser 6342 Oct 12 09:41 wp-content/uploads/2026/10/test-upload-150x150.jpg
-rw-r--r-- 1 cpuser cpuser 11076 Oct 12 09:41 wp-content/uploads/2026/10/test-upload-300x200.jpg
-rw-r--r-- 1 cpuser cpuser 48213 Oct 12 09:41 wp-content/uploads/2026/10/test-upload.jpg
The first line is the new attachment ID. The files belong to cpuser, the thumbnails were generated, and the mode is 644. Remove the test attachment with wp post delete 4917 --force, using your own ID.
- The write test from step 1 now prints
WRITE OK. Remove the.write-testfile afterwards.
Troubleshooting
- Only one site on a multisite network fails. Its folder under
wp-content/uploads/sites/<id>/was created or restored as root while the others were created by PHP. Find the path with the--urlcommand from step 7; thechown -Rin step 4 covers every site at once. - Only large files fail, small ones upload fine. Check
quota -sfirst. A nearly full quota accepts a 40 KB icon and refuses a 6 MB photo. PHP’s temporary file sits in/tmp, which on most cPanel servers is a separate filesystem outside your quota, so only the final move counts. If the large file instead ends with “HTTP error” or “exceeds the upload_max_filesize directive”, that is a PHP limit or image-processing problem, covered in “HTTP error” when uploading images to the WordPress media library. - The error returns after every nightly sync or restore. A job running as root is recreating folders. Give
rsyncthe--chown=cpuser:cpuseroption (rsync 3.1.0 or later), or run the job as the account user. Restores made from WHM → Backup → Backup Restoration set ownership correctly, so a recurring case points at a custom script. chownandchmodsucceed but the folder stays unwritable. Check for the immutable attribute:lsattr -d /home/cpuser/public_html/wp-content/uploads/2026/10shows aniamong the attribute flags when it is set, andchattr -ion that folder clears it.
When this is the wrong approach
Match the message word for word before you start. For “Unable to create directory”, run the same stat and chown one level up, on the parent uploads/ folder. The two temp-folder messages belong to the PHP side. If you see a different message each time, or none at all, start with the broader triage in WordPress image upload failures — disk, permission, plugin.
The method also assumes cPanel’s user model. On Plesk, DirectAdmin, or a plain Nginx and PHP-FPM server, PHP runs as psacln, the domain user or www-data, so the usernames change even though the stat and touch logic does not. If several accounts broke after one migration, fix the script that copies files as root before the next site moves. The PHP manual page for move_uploaded_file() and the WordPress reference for wp_upload_dir() document the two functions this article leans on.
Running WordPress that earns real money deserves an operator — Stack Harbor runs that stack under Enterprise WordPress; book an infrastructure consult.