2
votes

I am trying to upload a file in wordpress using the Media > Add New -- Option but when I click upload I get the following error:

Unable to create directory wp-content/uploads/2012/11. Is its parent directory writable by the server?

I have Wordpress 4.3.1 installed.

Thank you

EDIT: I am on a shared server with: host=i686-redhat-linux-gnu and Apache. I changed the permissions to 755 and 777 of wp-content/uploads but I get the following error:

“my_file.jpg” has failed to upload due to an error Unable to create directory wp-content/uploads/2012/11. Is its parent directory writable by the server?

Any ideas?

8
What operating system and web server do you have?doublesharp
did you run chmod with the -R option to make it recursive? if not, you may have only changed /wp-content/uploads and not /wp-content/uploads/2012doublesharp
if you run ls -la on the /wp-content/uploads directory, what is the owner and permissions set to? Do you know what user Apache runs as?doublesharp
I do not have console access to the server, how could I run the mentioned command? Thx :)JohnnyAce
If you don't have access how did you change the permissions/owner?doublesharp

8 Answers

5
votes

You need to set folder permissions for /uploads/ and possibly for /wp-content/ , too.

Typically, both folders should be 755. You may have to temporarily raise /uploads/ to 777 and upload an image (this will also force the server to change the folder permissions and user to the correct settings), but change it back to 755 right away.

It's easiest to set permissions with an FTP client. See Filezilla and FTP Clients « WordPress Codex.

And see Changing File Permissions « WordPress Codex for the correct Wordpress permission settings:

From the codex.wordpress: Typically, all files should be owned by your user (ftp) account on your web server, and should be writable by that account. On shared hosts, files should never be owned by the webserver process itself (sometimes this is www, or apache, or nobody user).

Any file that needs write access from WordPress should be owned or group-owned by the user account used by the WordPress (which may be different than the server account). For example, you may have a user account that lets you FTP files back and forth to your server, but your server itself may run using a separate user, in a separate user group, such as dhapache or nobody. If WordPress is running as the FTP account, that account needs to have write access, i.e., be the owner of the files, or belong to a group that has write access. In the latter case, that would mean permissions are set more permissively than default (for example, 775 rather than 755 for folders, and 664 instead of 644).

3
votes

ssh in and navigate to the wp-content folder and type in these 2 lines:

sudo chown -R www-data uploads/
sudo chmod -R 755 uploads/

or you can use the static and full path:

sudo chown -R www-data /var/www/wp-content/uploads/
sudo chmod -R 755 /var/www/wp-content/uploads/

Do not change it to permissions 777 because that is simply insecure

2
votes

I had the same problems last week. After trying all proposed solutions with no success, it occurred to me that we had SElinux enabled on the server. In my case, and maybe for many other people, SElinux was responsible of the error message:

Unable to create directory wp-content/uploads/2013/04. Is its parent directory writable by the server?

My solution is based on the one proposed here: http://doc-ok.org/?tag=selinux which could be more suitable to other people's needs.

In my case, my wordpress directory resides in my home folder on the server, to which I have ssh access. Otherwise you will have to ask your administrator.

Anyway, this is my solution.

chgrp -R apache wordpress #change wordpress with your base directory for wp..
#alternatively, chown the whole directory to apache
chmod -R 774 wordpress/wp-content #if chown by apache, the permissions can be more restrictive

In my case not only the folder ownership / group ownership had to be changed to apache. Also the SElinux label of wp-content directory had to be changed to either httpd_sys_rw_content_t or httpd_sys_content_t:

chcon -Rv --type=httpd_sys_content_t wordpress/wp-content

This did the trick for me.

More information on SElinux can be found for example at:

wiki.centos.org/HowTos/SELinux

and

fedoraproject.org/wiki/SELinux

1
votes

The /wp-content/uploads directory needs to be writeable by your webserver. Assuming that you are using Apache on Linux, and that it is running as user apache (change to your appropriate user) one quick fix for this would be to run the following command from your web root.

chown -R apache.apache wp-content/uploads
chmod -R 755 wp-content/uploads
1
votes

I faced the same issue and I found a better solution:

  1. go to cpanel > phpmyadmin
  2. select database
  3. open wp_options table
  4. make sql query SELECT * FROM wp_options WHERE option_name LIKE '%upload_path%'
  5. change the path
1
votes

this should fix it.

    sudo chown -R www-data:www-data wp-content/uploads

Do not change the permissions to 755 if it's not necessary. If it still doesn't work try:

    chmod -R 755 wp-content/uploads
0
votes

this works for me, after many weeks headache

sudo chown -R apache uploads
sudo chmod -R 755 uploads

assuming you're in wp-content

0
votes

for those who stumbled on selinux permission issue, here are the steps i made to fix them. We need to allow the following selinux boolean variables to allow installing of wordpress plugins from wordpress admin console using FTP. They are httpd_can_network_connect and ftpd_full_access. They can be activated by

setsebool ftpd_full_access on

setsebool httpd_can_network_connect on

also wp-content folder should be write permissible for the ftp user used for uploading.