Sometimes when migrating existing WordPress installs to a new server you may find an error when uploading images to your installation. That states the upload could not be moved.
“The upload could not be moved to /wp-content/uploads” folder.
This happens because the permissions on the account have not been set correctly. It could also happen in existing WordPress installs too. A recent update could have changed the permissions for the user.
Incorrect WordPress Permissions
To fix the WordPress upload could not be moved error you could chmod the directory WordPress is trying to upload your image to, to 777. But this would also bring into question several security concerns. The ideal permissions would be 755 or 744 on folders. You could also automatically fix this error using the fix permissions script.
The upload could not be moved
To fix this error securely you need root access to the server in question. So resellers cannot perform this fix. Only users with an NVME VPS server or Dedicated Server with access to the root account can follow the steps below.
- Login to your server with the root user account
- Find the cPanel users username
- Fix the Incorrect WordPress Permissions by using the below command but swap cPanel_user with the username of the account with the image upload problem.
- Ensure the path to the upload folder is correct.
cPanel Servers
chmod 755 /home/cPanel_user/public_html/wp-content/uploads
chown -R cPanel_user /home/cPanel_user/public_html
So if the cPanel user reporting this was called first2host the command we would issue would be
chmod 755 /home/first2host/public_html/wp-content/upload
chown -R first2host /home/first2host/public_html
Barebones Servers
Finally, if you are using a server without a control panel, the user who runs the files will likely be different. Additionally, the path will likely be different. In Linux VPS Servers the user usually needs to be www-data. The command to use would therefore be
chmod 755 /var/www/domain.com/wp-content/upload
chown -R www-data:www-data /var/www/domain.com/
Once this has been done you should try to upload your image again and this time the upload should work. This is only to be used on servers where you have access to SSH by using the root account and running cPanel.
High Availability WordPress Hosting
Choose High Availability WordPress Hosting for absolute stability.