Cannot upload media via Wordpress uploader
23:24 03 Jun 2010

This has to do with media uploading in Wordpress.

Every time WP creates a folder for new uploads (it organizes uploads by year and month: yyyy/mm), it creates it with the "apache:apache' user and group, with full access to all (777 or drwxrwxrwx).

However, after that, WP cannot create a folder within that folder (e.g.: mkdir 2011 succeeds, but mkdir 2011/01 fails). Also, uploads cannot be moved into these newly created folders even though the permissions are 777 (rwxrwxrwx).

Once a month, I have to chown the newly created folders to be the same as user:group as the rest of the files. Once I do that, uploading works fine (which doesn't make sense to me The really frustrating part is that this problem doesn't exist in other WP installs on other domains on the same server.

* I wasn't sure if this should be here or on serverfault.


Edit: The containing directory /.../httpdocs/blog/wp-content/uploads has the correct ownership

drwxrwxrwx 5 myuser psaserv 4096 Jun  3 18:38 uploads

This is a Plesk/CentOS environment hosted by Media Temple (dv).

I've written the following test script to simulate the problem

The script always creates the first directory mkdir($d) successfully. On domain A, where the WP problem is, it cannot create the nested directory mkdir("$d/$d"). However, on domain B, both directories are successfully created.

I am running each script at /var/www/vhosts/domainA/httpdocs/tmp/t.php and /var/www/vhosts/domainB/httpdocs/tmp/t.php respectively I checked the permissions on tmp, httpdocs, and domain[AB] and they are the same for each path. The only thing that differs is the user.

wordpress upload permissions