www.question-defense.com | Engage: Visit :: Login :: Register
Translate to English Übersetzen Sie zum Deutsch/German Переведите к русскому/Russian Μεταφράστε στα ελληνικά/Greek Vertaal aan het Nederlands/Dutch ترجمة الى العربية/Arabic 中文翻译/Chinese Traditional 中文翻译/Chinese Simplified 한국어에게 번역하십시오/Korean 日本語に翻訳しなさい /Japanese Traduza ao Português/Portuguese Traduca ad Italiano/Italian Traduisez au Français/French Traduzca al Español/Spanish
1

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: Unable To Create Directory

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:

  1. 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>
    
  2. 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.

  3. 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
    
  4. 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)
    
  5. 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.

    WordPress Image Upload In Post

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.


WordPress

Jessica Neuman Beck. Peachpit Press 2009, Paperback, 288 pages, $18.79

4.0


A Step by Step Wordpress Tutorial For Beginners

Mati H Fuller. Bigger Vision Books 2009, Paperback, 122 pages, $17.95

4.0

DeliciousStumbleUponDiggTwitterMixxTechnoratiFacebookNews VineLinkedInYahoo! Bookmarks
Related posts:
  1. WordPress: Unable To Upload To The Media Library After Moving Servers I recently moved a WordPress site from one location on...
  2. WordPress File Upload Error: The uploaded file could not be moved to When attempting to upload files via the WordPress admin to...
  3. Enabling FORCE_SSL_ADMIN in WordPress Breaks Image/Media Upload In The WordPress Admin I have been having a problem with the media browser...
  4. How to Update Wordpress Blog URL Below are a couple simple steps to update your Wordpress...
  5. How To Remove The NextGen Gallery Plugin From Your WordPress Blog I have used the NextGen Gallery WordPress plugin on a...

Tags: , , , , , , , , , , , , ,
Leave a Reply