While trying to upload the image in my WordPress post, I received an error saying:
The uploaded file could not be moved to wp-content/uploads
The server which got this error is:
- vps (unamanged with ssh/root access)
- ubuntu 14.04 minimal
- nginx with php-fpm and mysql
- NO ftp
- WordPress 4.0
The directories were in standard file permission when I moved the files to the vps.
The solution to this error is quite simple. While surfing around the net I found out some people suggesting making your uploads directory 777, well that’s the worst idea of all. What’s the point in making your whole server vulnerable, just to upload an image. In fact why to chmod it 777 and make it writable to the public when you can simply make it writable by your WordPress only?
The solution to fix this error is simply logging into your ssh via terminal or any other client, and running the following command to allow your WordPress to write itself on the directory (copying exactly what I did):
chown -R www-data:www-data /var/www
chown -R www-data:www-data /var/www/websitename/path/to/wp-content/
Please note, if you’ve changed the root user (which is a good thing) then you would have to use “sudo” before these commands.
Also, note that I used path to wp-content. Now I’m not sure if the first command will fix it for your or not, I just ran it anyway to fix the issue.
Hope it solves “The uploaded file could not be moved to wp-content/uploads” issue for your WordPress on nginx.