I haven’t posted to my personal WordPress blog in months because I have been busy writing QD articles and working on the QD Tools section. So I got a comment posted to my personal blog tonight that inspired me to finally get back to making a blog post on the WordPress site that houses my personal blog. During the post I wanted to upload an image of my daughter which I typically do using the “Add an Image” button located in the WordPress admin “Add New” post interface. The “Add an Image” button by default allows two different methods of uploading images via your web browser which include the Flash Uploader and the Browser Uploader. On Question Defense I use a modified version of the Browser Uploader however on my personal WordPress blog I always have used the Flash Uploader. Tonight when I attempted to add a post I received an error which I initially thought to be related to permissions however that was not the case as I explain below along with steps to resolve the issue.
WordPress Image Upload Error:
WordPress Image Upload Error Text: Unable to create directory /var/www/web3/web/wp-content/uploads/2010/02. Is its parent directory writable by the server?
Initial Steps Taken To Troubleshoot WordPress Image Upload Error:
Initially I figured that I must just have permissions incorrect in the “uploads” parent directory as stated in the error text so I logged in to the server to check permissions. I was surprised to find out that the issue was not with permissions on the uploads directory or any sub directories underneath of the uploads directory. I was a little baffled at this point and then I remembered that I had moved the site from one server to another a little over 3 months ago. Since it had been so long since I posted a blog I simply had not noticed a configuration option I had forgotten to change and if I had looked closer at the error I would have realized that the directory it was attempting to write to was incorrect. First I did a quick grep on the entire site directory to see if any files included the incorrect path and was unable to locate any files displaying the incorrect path. Then I remembered that within the WordPress MySQL structure I needed to locate and modify the upload_path variable. Below I describe locating the upload_path variable and modifying the upload_path variable in MySQL.
Modify Image Upload Path Variable In The WordPress Site MySQL Database:
- Launch MySQL CLI: You can either make this modification using phpMyAdmin or via the MySQL command line. I personally prefer the MySQL CLI so my instructions explain how to modify the upload_path option using the MySQL server command line interface. First launch MySQL using the command displayed below after modifying the name database name which is “personalblog” in the example below.
Launch CLI Connection To WordPress MySQL Database:
- [root@ali ~]# mysql -u root -p personalblog
- Enter password:
- Reading table information for completion of table and column names
- You can turn off this feature to get a quicker startup with -A
- Welcome to the MySQL monitor. Commands end with ; or \g.
- Your MySQL connection id is 2749145
- Server version: 5.0.45-log Source distribution
- Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
- mysql>
- Verify Upload Path Option Value: Once connected to the database we need to verify the path is actually incorrect by checking to see what the option_value is for the option_name upload_path. This can be done using the MySQL command listed below. You can obtain the same results using the phpMyAdmin interface but again the MySQL CLI is what I prefer versus the web interface provided by something like phpMyAdmin.
Verify WordPress MySQL option_name upload_path Value:
- mysql> select * from wp_options where option_name = 'upload_path';
- +-----------+---------+-------------+--------------------------------------+----------+
- | option_id | blog_id | option_name | option_value | autoload |
- +-----------+---------+-------------+--------------------------------------+----------+
- | 60 | 0 | upload_path | /var/www/web3/web/wp-content/uploads | yes |
- +-----------+---------+-------------+--------------------------------------+----------+
- 1 row in set (0.00 sec)
I knew at this point that the correct upload path for images should be “/var/www/clients/client1/web2/web/wp-content/uploads” instead of the “/var/www/web3/web/wp-content/uploads” path that was currently configured. So again this was an error caused by myself when i moved the site from one server to another.
- Modify WordPress Upload Path: So I needed to now modify the option_name “upload_path” in the wp_posts table located in the sites WordPress MySQL database. This can easily be modified from the MySQL command line interface using the syntax located below.
Modify WordPress MySQL wp_options option_name upload_path option_value:
- mysql> update wp_options set option_value = '/var/www/clients/client1/web2/web/wp-content/uploads' where option_name = 'upload_path';
- Query OK, 1 row affected (0.00 sec)
- Rows matched: 1 Changed: 1 Warnings: 0
- Verify Upload Path Option Value: After you make the modification verify that the value of the option_name upload_path was modified successfully using the same command displayed in step two and again below.
Verify The WordPress Image Upload Path Was Modified:
- mysql> select * from wp_options where option_name = 'upload_path';
- +-----------+---------+-------------+------------------------------------------------------+----------+
- | option_id | blog_id | option_name | option_value | autoload |
- +-----------+---------+-------------+------------------------------------------------------+----------+
- | 60 | 0 | upload_path | /var/www/clients/client1/web2/web/wp-content/uploads | yes |
- +-----------+---------+-------------+------------------------------------------------------+----------+
- 1 row in set (0.00 sec)
- Upload Image To WordPress Post: Now that the image upload path has been set correctly in the wp_posts WordPress MySQL database attempt to upload the image again. If you have verified permissions and there are no other issues you should now be able to successfully upload an image.
You should now be able to upload images to posts in the future without issue. If you continue having issues after you have verified the upload path and verified permissions I would start troubleshooting from the web server logs to attempt to locate the issue.
this didnt work for me- i now get a downoad prompted when i visit the homepage trying to download from the upload folder – not sure what i did wrong here… hmmm
Hello Jamie,
It sounds as if you may have modified the wrong option in the WordPress database. Make sure before any other changes are made that you backup the table you are modifying so you always have something to go back to. If you list your upload_path variable information I may be able to assist but again it sounds as though something else was modified on accident. If you found a solution let us know what it was so others may benefit from the information.
Thanks.
alex
Hi there this is the closest I have come to finding out how to redirect the command line in the database, I’ve never used MySQL CLI. How would this be done through hpMyAdmin?
2011 wordpress 3.0.4
Hello JamesSmith,
I believe you mean phpMyAdmin and if so you can enter SQL commands by clicking on the database you want to execute the commands on and then clicking the SQL tab. I would recommend being 100% sure before you issue any commands and also make sure to backup the entire MySQL database before making any changes or issuing any commands.
Thanks.
alex
Hi,
This happen to me when I upgraded to 3.0.4 :/
I found your post and I’m logged into my database…
I don’t understand how you knew that “I knew at this point that the correct upload path for images should be “/var/www/clients/client1/web2/web/wp-content/uploads” instead of the “/var/www/web3/web/wp-content/uploads” path that was currently configured” How did you know what the correct path should be?
Thanks so much.
Best,
Chelsea
Hello Chelsea,
To be honest I don’t know specifically how I knew that this was incorrect however you can track this down by going into the folder that is specified via SSH or directly from the terminal on the server and type “pwd” followed by enter which will provide you the true path to the uploads folder in question. If the uploads folder path is completely wrong you could try “locate uploads” or by using find.
Hope that helps.
Thanks.
alex
Hi Alex
That goes for you.
I have just installed wordpress 3.0.4 to my server. It runs windows server 2003 and IIS.
Installation process finished perfect. I ran installation, even better that I wished. Everything seemed perfect.
I made my first posts and I really finished, at list amazed of the results.
Disillusion arrived when I tried upload an image. I got the same, almost the same, error massage as your.
With just a variation. Your massage was:
“WordPress Image Upload Error Text: Unable to create directory /var/www/web3/web/wp-content/uploads/2010/02. Is its parent directory writable by the server?
My massage was:
WordPress Image Upload Error Text: Unable to create directory C:\inetbub\wwwroot\wordpress\wp-content/uploads/2010/02. Is its parent directory writable by the server?
As you can see, in my error message, the part of the message that makes reference i existed folders, C:\inetbub\wwwroot\wordpress\wp-content, is in Windows format, \ .
The part that makes reference to new folders creation, /uploads/2010/02, is different format, / , that is linux or any other format, I have no idea about these other formats.
Can you suggest any solution about this problem?
Thanks
Giorgos
Hello Giorgos,
Sounds like you need to modify the permissions of he upload folder to 777. In windows you can right click the folder and modify the permissions that way.
Thanks.
alex
Hello Alex
Thank you very much for your response.
Is the first thing I did what you propose me. But the problem is that the left direction vertical bar — / —- , means nothing to folders creation.
The right direction vertical bar, — \ —, means folder to it.
The problem is that wordpress is trying to create a folder using the left direction vertical bar — / — and for windows it means error.
My question is if you know any tip or trick to use on wordpress, so that when it will have to create the uploads folder, will use the right direction vertical bar — \ —.
Thank you for your attention.
Giorgos
Hello Giorgos,
You might try changing the upload path to “/wp-content/uploads” without the quotes. I read online where that resolved the issue for others running on a Windows server with IIS. Personally I only host web sites on Linux based platforms so I have not had this exact experience.
Thanks.
alex
Hi,
I checked the MySQL but everything is in order. This “/” and “\” issue is what I am facing too though I doubt it has anything to do with it. The site that I want to convert into wordpress is among many domains that the developer decided to host on the same godaddy account. Normally using GOdaddy’s own app feature is seamless but this has created new issues.
Also, I am unable to change write permissions using filezilla..I get the message “comman not understood”
Any help?
Hello pegu,
Sounds like your issues are outside the scope of this article and that you may have other issues other than simply the WordPress upload directory issue.
Thanks.
alex
Figured it. Mac has a funny way of giving permissions to files that are not generated within the system itself. When I unzipped the files from WordPress to install into the website, the files did not have local write permissions. So this time, before uploading all the files to the server, I made all the files “open”. After that I used Godaddy’s file manager to give read and write permission to the wp-content folder. It works fine so far. Phew. This whole process made me learn a lot of stuff, including MYSQL servers that I learned from here- thanks!
Hello pegu,
Glad to hear you got it all sorted! Thanks for taking the time to follow up!
Thanks.
alex
Great post, thanks for the help! Same thing happened to me: moved my blog to a different server, but didn’t upload anything for awhile, went to upload an image and recognized that WordPress was trying to use the upload path from my old server. Glad to know it was a simple solution, which I figured it would be, I just had no idea in which table the upload path was specified. Thanks again, cheers.
Hello Andrew,
Thanks! Glad you got it worked out. Thanks for taking the time to leave feedback.
Thanks.
alex
heh, i thuhgot i was imagining the .meta(-)sep weirdness. i get dislexic with dashes and underscores and whatnot.don’t forget there’s also all that pingback goodness.