For some reason when I try to upload an image to my blog I get an error message saying that WP can't create a folder under the relevant directory (wp-content/uploads/2010/09) and it's asking if the folder above it has write permissions. The parent folder indeed has write permissions. I tried creating the folder manually and it still shows the same error message.
-
@Lea, In order to provide an accurate answer to you question more details are needed. Is this a new WordPress installation? If not were you able to upload images in the past? What permissions do the current upload directories have and what did you change them to? Is PHP running under the username or a group name like nobody or www-data? Are your WordPress files owned by a username or username:groupname?– Chris_OSep 6, 2010 at 20:44
-
@Lea: To add to the questions by @Chris_O, who is your webhost? To administer are you using FTP, CPanel or other? Are you on Mac or PC? When you say it has write permissions, what are the numbers it has?– MikeSchinkelSep 7, 2010 at 1:22
-
What was the error massage Lea ?– Tal GaliliSep 7, 2010 at 5:03
-
I use Site5 for hosting. The WP version is 3.0.1 I uploaded images successfully until this problem. This isn't a new blog. I haven't touch the permissions and that's why it's surprising. All folders from Uploads and down have read/write permissions. I use the Site5 FTP and/or edit via WP. The numbers are 7 5 5.– LeaSep 8, 2010 at 12:51
-
@Lea: Do any of these answers below help you solve your problem? If so, please up vote them to thank the people who've helped you, and pick the best answer so your question doesn't remain in the "unanswered" list.– MikeSchinkelSep 10, 2010 at 20:31
7 Answers
@Lea,
This error happens when PHP (WordPress) can't write to the file. This is caused by not having write permissions or the username or group that PHP (WordPress) is running under doesn't have permission to write to the file.
755 permissions will allow WordPress write permissions when PHP is running as the username under most shared host plans.
Some FTP programs will allow you to change the user and group assigned to the folders. You can also make this change using Cpanel's file manager.
The folders should have the same username as your Cpanel account.
Some server environments require you to use 777 permissions for PHP to have write access. This is not secure in a shared hosting environment. You can change your permissions to 777 temporarily to see if that allows you to upload photos but MAKE SURE YOU CHANGE THEM BACK TO 755 WHEN YOUR DONE.
Your hosting provider should also be able to provide help in this situation.
This seems to be a common problem. I've dealt with it a while ago too. In my case, all of the proper directories had 777 permissions. Here is my solution, along with a bunch of others that I've tried:
- In my situation, I had to make sure the FTP user account I was using for WordPress had read/write/execute access. Inexplicably, the original user account had its permissions reset, perhaps by the web host or something. We were never able to determine what caused this change. Using an admin account, we were able to upload images without issues again.
These tips come from a thread from WordPress support for WP 2.5 (you can refer to the link for more info on any of these items):
- Make sure you uploaded all the WordPress files correctly.
- Clear your browser cache, restart your browser.
- Update your Adobe Flash to the latest version (esp you Linux users!)
- Disable your plugins and see if the buttons appear. If so, reactivate one by one until they don't appear any more.
- Upgrade all your plugins as well.
- The highly popular Bad Behavior plugin breaks the uploader. Upgrade it to 2.0.14 (or later).
- mod_security might be causing problems. Disable it to see if that is the problem.
- Try a smaller image, in pixels. Filesize is largely irrelevant, it's the width and height of the image that matters.
- Sometimes the problem is with the image itself. WordPress uses the normal PHP functions for working with images, which are in the "GD" library. GD has problems with certain types of images. One particular image type that it cannot handle is grayscale images. If your image is black and white or grayscale, then make sure that it's a FULL COLOR image.
- A new issue in WordPress 2.6 occurs when you have a custom directory for file uploads. The upload will work, but the link/thumbnail link will be wrong and so the image won't appear.
- Do you have custom settings on the Settings->Miscellaneous screen? If so, make sure that they are correct. The upload directory must not have a leading slash in front of it (uploads instead of /uploads), and the URL must not have a slash at the end of it.
This fixed it for me: I was logged into WordPress using the user name I created when installing instead of my original cpanel user name that had proper permissions on my account. I fixed the issue by creating a new WordPress admin user using the same username and password as my cpanel user. Logged out and back in as that user and problem solved.
Try to add permission to the parent folder which is the "uploads" directory.
-
The uploads folder also already has write permissions.– LeaSep 8, 2010 at 12:51
Try uploading the images using FTP software and see if it gives same error.
Also check if there is any plugin auto-creating a thumbnail of the image uploaded in some other directory
Also try changing the default file upload location in case this error insists on showing up
Hope any of this helps (:
One thing that occurred to me - WP will tell you that it can nto copy file to /wp-content/upload
even when all permissions are right.... if
upload_max_filesize
in php.ini
is too small (say 2M and you try to upload 3.5MB file)!
Hope that helps all thsoe who have right permissions but still can not upload!
In my case, this was caused by the upload_path
option in the wp_options
table having the wrong value.
The solution was to empty the option field. This makes WordPress use the default upload path (<wproot>/wp-content/uploads
)
MySQL query to do this:
UPDATE wp_options SET option_value = '' WHERE option_name = 'upload_path'