Upload file wordpress

22,550

Solution 1

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).

Solution 2

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

Solution 3

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

Solution 4

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

Solution 5

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
Share:
22,550
JohnnyAce
Author by

JohnnyAce

Updated on April 08, 2020

Comments

  • JohnnyAce
    JohnnyAce about 4 years

    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?

  • VaTo
    VaTo almost 5 years
    In my case the /uploads directory was already "httpd_sys_content_t" but it was still giving me the error. I had to change it to "httpd_sys_rw_content_t" in order for me to work