I have started noticing this with a few of my OpenLiteSpeed wordpress sites now, running WP 6+.
Each month when the new monthly wp-uploads directory is created (eg October/November /uploads/2021/10/ /2021/11 etc) , the permissions are WRONG.
I get the error “the uploaded file could not be moved to…” and it appears that the folder has been created with root as the owner, and not www-data.
Numerous times I have run the command:
sudo chown -R www-data /var/www/mysite/wp-content/uploads
I recursively run this command on both the uploads directory and wp-content parent directory, but it seems i’m having to run it every month on the new folder created in uploads.
Obviously something is wrong here, can anyone possibly advise what the problem is here?
Not entirely sure how to add an image here but all of my folders are www-data:www-data, it seems the new ones are being created with the wrong permissions.
Any advice much appreciated. Thanks. Its getting annoying and i’m losing business because my website relies on users adding content and listings, and if they cant upload images i’ll be losing money.
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Enter your email to get $200 in credit for your first 60 days with DigitalOcean.
New accounts only. By submitting your email you agree to our Privacy Policy.
Hello there,
This should be related to having WordPress cron jobs running as the root username.
We also have an article which covers this issue and possible ways to sort out the problem which you can check here
https://www.digitalocean.com/community/tutorials/how-to-fix-the-uploaded-file-could-not-be-moved-to-in-wordpress
Regards
Similar to this issue (https://wordpress.stackexchange.com/questions/231523/wordpress-monthly-upload-directory-owner-set-to-root), please check your wp-cron job.
Hi @mburdett555,
I understand you. Specifically what is the user that assigns you in the folders? Are you using PHP-FPM ?
I recommend you check out Hardening Wordpress, provides a lot of information on the subject.
Let me know more information.
Sergio Turpín