If you are seeing any of the following errors when you try to upload/import media into WordPress’s media library then this tutorial is for you. It will show you how to fix this annoying error.
- Unable to create directory wp-content/uploads
- Unable to create directory /wp-content/uploads/ Is its parent directory writable by the server?
- Unable to create directory wp-content/uploads/2013/02
I personally faced this issue a while back and wrote a quick fix tutorial on this subject. However, a lot has changed since then so it is time to publish an updated version of the tutorial.
There are a few different possibilities for this error to show up. I will try to cover all the possibilities so hopefully one of them will help you fix the issue.
Fix #1: Update/Change the Uploads Directory Settings
This is the easiest option to try and solve this error so you should try this one first.
- Log into your WordPress admin dashboard
- Go to Media Settings menu (Settings -> Media)
- Enter wp-content/uploads in the “Store uploads in this folder” text box
- Save the changes by hitting the “Save Changes” button and you are done
The important thing here is to make sure you only enter the following in the “Store uploads in this folder” field:
Fix #2: Manually Change the Folder Permission
If the above fix doesn’t work then try this option. This method requires you to change the file/folder permissions on your server. If you don’t know how to do this then read the tutorial on how to change permissions.
- Change folder permissions on the wp-content directory to 775 and try the upload again
- If it fails, change the permissions to 777 and try again
- if it still fails then do step 1 and 2 for the “wp-content/uploads” directory too
Once you can successfully create the folder and upload the media, be sure to return the permissions on wp-content directory to 755 (your folders should have a permission of 755 for security reasons).
Fix #3: Use This If Your Server is Using Ubutu
The webserver (Apache) runs as user www-data and group www-data by default on a Ubuntu system. If the files/folders are not owned by this user (www-data) then the webserver will be unable to write changes to them.
Change the filesystem permission on the folder (where the web application wants to write to) to the “parent directory” as mentioned in the error message.
For example, do (prepend with sudo if you’re not the current owner and need to elevate your own permissions in order to do it):
chown www-data /path/to/directory
to make www-data the owner which makes it writeable usually, or another approach via groups:
chgrp www-data /path/to/directory
chmod g+w /path/to/directory
Fix #4: Try This If Running PHP in Safe Mode
If your server is running PHP in safe mode then know that it won’t allow you to create files or directories if your PHP scripts and upload directories belong to different users. So try one of the following solutions:
- Change the owner of scripts and upload directories (your hosting provider can do this for you)
- Disable PHP safe mode (your hosting provider can do this for you)
Fix #5: Use This for XAMPP (LocalHost Installs)
If you have installed XAMPP to run WordPress on your local PC for testing and you are seeing this error then try the following.
Reset the ownership of the WordPress instillation to nobody. You can do this by running the a command in the command line/terminal.
- Windows System: Start -> Programs -> Accessories -> Command Prompt
- Mac: Applications ->Utilities -> Terminal
sudo chown -R nobody:staff /applications/xampp/xamppfiles/htdocs/wp
Hopefully one of the above solutions should help you fix the unable to create directory error in WordPress.
If none of the above solution works then maybe it is time to look for another hosting provider for your WordPress site.
Please feel free to share any other techniques/fixes for this error in the comment section below.