Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The uploaded file could not be moved to wp-content/uploads

I am trying to upload pictures in WordPress but I get this error:

The uploaded file could not be moved to wp-content/uploads.

I am running it in localhost but the answers I have found are to change the folder permissions to 777 on the server.

I tried making an uploads folder myself, but it's of no use and there is no option to change the folder permissions to anything except read and write.

I'm using XAMPP on Mac OS X; I'm new to WordPress - how can I fix this?

like image 953
Wang'l Pakhrin Avatar asked Sep 26 '13 05:09

Wang'l Pakhrin


People also ask

Has failed to upload the uploaded file could not be moved to wp-content uploads?

'The uploaded file could not be moved to wp-content/uploads/' 'Unable to create directory wp-content/uploads/~. Is its parent directory writable by the server? ' To fix this error, you'll need terminal access to the server where your WordPress site is installed.

How do I get to wp-content uploads folder?

The specific folder where the image files are stored in WordPress is called the uploads folder located inside the /wp-content/ folder. Inside the uploads folder, your media files are stored by year and month folders. Additionally, you'll also see folders created by your WordPress plugins to save other uploads.


1 Answers

It is most likely a permissions issue. Find the user processes running on the site by navigating to your sites wp-content folder on the server your site is on. Then type this;

ps aux | egrep '(apache|httpd)'

Ignore root, but look at the other users

root      2507  0.0  0.3 423820 14328 ?        Ss   Aug04   0:51 /usr/sbin/httpd
apache    4653  0.5  1.9 483900 77252 ?        S    16:27   0:14 /usr/sbin/httpd
apache    4654  0.5  2.1 500160 84912 ?        S    16:27   0:13 /usr/sbin/httpd
apache    4656  0.8  2.0 484708 78712 ?        S    16:27   0:21 /usr/sbin/httpd
...

For me it actually was apache (usually www-data). Finally change the users of the uploads folder to this user;

sudo chown -R apache:apache uploads

(make sure you are in the directory above the uploads folder when running this command)

This will permit the correct user to access this directory using the correct access permissions of 755.

By using the dreadful '777' advice of others, you are simply allowing the correct user to access the directory assigned to the incorrect user - as well as anyone else who can access that directory!

like image 183
myol Avatar answered Sep 28 '22 03:09

myol