#2345 closed defect (bug) (wontfix)
Wordpress fails to create upload directories, even when parent is writable
Reported by: | sjmurdoch | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 2.0 |
Component: | General | Keywords: | bg|has-patch bg|commit |
Focuses: | Cc: |
Description
When I attempt to upload a small text file to Wordpress, it fails with the error message:
Unable to create directory /var/sites/lbt/wp-content/uploads/2006/01. Is /var/sites/lbt/wp-content/uploads/2006 writable?
The webserver runs as user www-data, group www-data and the directory is writable
$ ls -ld /var/sites/lbt/wp-content/uploads/2006 drwxrwxr-x 2 www-data lbt 4096 Jan 27 18:10 /var/sites/lbt/wp-content/uploads/2006
The error message comes from wp-includes/functions-post.php:874
if ( ! @ mkdir( $pathym ) ) return array('error' => "Unable to create directory $pathym. Is $pathy writable?");
If I remove the "@" to show errors, I get the following output:
Warning: Wrong parameter count for mkdir() in /var/sites/lbt/wp-includes/functions-post.php on line 874
Unable to create directory /var/sites/lbt/wp-content/uploads/2006/01. Is /var/sites/lbt/wp-content/uploads/2006 writable?
As indicated by the error message above, the mode flag is not optional in PHP < 4.2. Replacing the call with the following fixes the problem:
if ( ! @ mkdir( $pathym, 0775 ) )
I should add: