I noticed this while setting up a WordPress (build 2.9.1) blog on a SUSE 10.3 Linux Server running PHP 5.2.5.
I encountered the following error when uploading or installing a plugin from the Add new section:

Could not create directory. /[WordPress Root]/wp-content/plugins/[My Plugin]/
I reviewed my file permissions and they appeared to be correct. I then proceeded to take a look at WordPress' wp-filesystem manager.
Looking at the file: [WordPress Root]/wp-admin/includes/class-wp-filesystem-direct.php, It appears that the path value being sent to the mkdir method contains a trailing slash, which is causing @mkdir to barf.
This is a bug reported in php 5.2.5 (http://bugs.php.net/bug.php?id=42739)
Best advice is to upgrade to the latest version of PHP.
However, if you are not in a position to upgrade, you can add the following line to the start of the mkdir method in the file [WordPress Root]/wp-admin/includes/class-wp-filesystem-direct.php
$path = preg_replace('(/$)', '', $path);
This will allow WordPress to bypass the PHP Bug.





5 comment(s) so far
PHP Bug Validator provides automatic execution history logging of applications as they run. PHP Bug Validator allows you to perform execution history.
I have just downloaded the latest daily build and they have fixed the trailing slash issue but this still happen on my server.
If I create the upgrade directory myself and set the permission to full I then get.
Could not create directory. /user/htdocs/blog/wp-content/upgrade/wordpress-importer.tmp
Help please.
Hi,
Firstable,congratulations on Your beautyful Web Site.
We are looking to find link partners for our Iphone website.We sell all kind of Iphone 4 accessories.If you are interested,please send us your link details and will add you link immediately.
Best Regards,
John
Works like a charm, I was thinking this was like a chmod type of fix, had no idea my php was already outdated so fast! Thanks for the patch!
I've try and still error....help