Solve can’t upload image issue in WordPress

WordPress

Recently I rebuilt the system for my server and created a new WordPress blog, but when I tried to upload pictures to the post, the upload process was interrupted by an error, it says that “The uploaded file could not be moved to ../wp-content/uploads”, what’s up?

Imperfect Solution

So I was googling and found someone said that you should set the permission of wp-content/uploads folder to 777 like below:

chmod -R 777 wp-content/uploads

Yes, after I changed that, it was worked fine, however, you’d better don’t do that immediately! Don’t you think it’s dangerous for the server security? Of course, you may say that just change the permission back to 755, that’s OK! Yes, but it’s not a perfect solution, because when you upload the picture in the next time, you have to change the permission again and again. So, what shall we do?

Perfect Solution

Actually the root of the problem is the user and group setting on your server. Just try the following commands.

chown www-data:www-data wp-content/uploads
chmod -R 755 wp-content/uploads

For the details of chown and chmod command usage, you can refer to their wikipedia: [chmod] and [chown]

Then, tried to upload the picture again, it was working like a charm!

Leave a Reply

Your email address will not be published. Required fields are marked *

×