WordPress MU and File Upload Permission Issues

Does this sound familiar to you: “The uploaded file could not be moved to the upload folder.” If it does and you’re trying to find a solution, read on.

This took a bit for me to figure out, had me banging my head for a little awhile. I’m on Media Temple (dv) Dedicated Virtual hosting and have two installations of WordPress Multi-User (MU) each pointing to a different IP address. One day, I was trying to upload a file via FireZilla FTP to my /wp-contents/blogs.dir/[blog.id]/ folder and it said permission denied. I thought that was odd, but stupidly did a CHOWN on the entire httpdocs folder (this is Media Temple’s public_html folder) to set it to the account user. Problem solved. Unfortunately then the WordPress Media uploader stopped function and I was getting the message: “The uploaded file could not be moved to the upload folder.”

[showads]

So did a Google search and found a few informative forum threads discussing the problem and possible solutions:

  • CHMOD the wp-content folder to 777, which is a HUGE security risk. I don’t recommend you do this, but it works for some people.
  • CHMOD the wp-content folder to 755, doesn’t really work
  • CHOWN the blogs.dir folder to nobody, BINGO!

So the answer turns out to be that the blogs.dir folder’s ownership has to be set to nobody or essentially the server. If the ownership is set to the user account, you are able to upload content to the blogs.dir folder, but WordPress Media Uploader can no longer. So to solve the problem, I SSH into the server and browsed to the wp-content folder and:

chown apache blogs.dir -R

Afterwards, the WordPress Media Uploader was able to upload files once again. It’s funny because WPMU version 2.8.1 and prior never had an issue like this, so not sure what was changed.

2009-01-25 UPDATE: So I ran into the permissions issue again. Oddly, it cropped up after I added another account on my MediaTemple (dv). I followed my steps above and it no longer seemed to work for me. After spending a couple of frustrating hours on Google for a solution, I decided to take some people’s advice and turn-off Safe_Mode (read more). Obviously there are some inherent security issues with doing so, but since I don’t grant anyone else access to my web server, it shouldn’t be a huge problem. I also had to do:

chown apache:apache blogs.dir -R

since that was the account my web-server uses to write. Things are now working as they should.

2011-01-14 UPDATE: See the directions on this website as well: http://hereshowi.com/wordpress/fix-wordpress-permissions-on-mediatemple-dv-server.

13 thoughts on “WordPress MU and File Upload Permission Issues”

  1. Hi Richard,

    I’m trying to get MU installed on a dv server too and having loads of problems with the file upload thing.

    It looks like the problem is one of folder ownership and permissions. WordPress seems to be creating a folder under blogs.dir owned by “apache” and then is unable to write into it. If I change the ownership of the folder to the FTP user manually it can then create folders under it, but again creates them with the wrong owner. I *could* fix them manually but I’d have the problem every time someone creates a new blog

    Have you ever seen anything similar? I’ve tried setting the owner of blogs.dir to both “nobody” and “apache” and it doesn’t fix the problem.

    Totally stumped on this one

    Owen

  2. Scratch that. I’ve managed to resolve the problem!

    I’ve noticed that on Mu installation it gives you the option to CHMOD your folders to 777 for installation or CHOWN them by Apache .. I had orignally done the former.

    After reading your blog post, I CHOWNed the whole of httpdocs folder to apache and it seems to have resolved all the issues I had!

    Thanks for the inspiration

  3. I’m having the exact same problem and I have been pulling my hair out for ages now. I’m not on a DV server, but it sounds like it must be a file/folder ownership problem. When I try to upload a file, WPMU actually creates the correct folders i.e. blogs.dir/1/files/2009/08/ but then is unable to write to them (it seems).

    The ‘owner’ of these folders that are created by wpmu for me, is ‘www’ – which I would imagine is the equivalent to ‘apache’ for you. I have tried CHOWNing them to be my SSH username, that didn’t work.

    I was wondering, because I haven’t got SSH set up via PHP on this box, that it might be causing problems (I can SFTP using WinSCP for example, but don’t have the necessary library for SSH to work via PHP).

    Properly stumped!

  4. Well bugger me backwards and call me Sheryl, a friend of mine has managed to solve my problems. The problem was with the ABSPATH definition – which is defined in wp-load.php and is then ‘checked’ in wp-config.php. If that isn’t set correctly then everything breaks as we have been finding above.

    normaly, ABSPATH is defined thus:

    “define( ‘ABSPATH’, dirname(__FILE__) . ‘/’ );”

    however, I had to modify it to something similar to the following:

    define(‘ABSPATH’, ‘/users/mylocation/sites/www.mydomain.com/’);

    This is a horrible hack, but frankly my dear, I don’t give a damn. 🙂

  5. Owen & Richard: Sorry for the delayed reply, but sounds like you both managed to resolved the issue! Thank you for sharing so that other readers may benefit.

  6. im running out of hair, the coffee is almost out and it’s been two weeks with less sleep and still i haven’t found the solution to this issue not able to upload my media files,

    Unable to create directory /var/www/vhosts/mydomain.com/httpdocs/wp-content/blogs.dir/1/files. Is its parent directory writable by the server?

    i’ve tried Richard’s “hack” and Owen’s CHOWN thing but still it didn’t worked for me…

    badly need help before i run out of hair!!

    1. Can you SSH into your server and look at the permissions for that specific folder (1)? Also check to see if the folder files exist also. If not, create it and make sure it has the right permissions. Try doing a CHMOD 777 wp-content -R and see if it works. If it still won’t right, it means it’s a permission issue and your webserver doesn’t have the rights to write to that folder(s). So here’s another thing, check your other WordPress files and see who the owner is. You might be surprised to find that the owner is not Apache, yet it works. Report back if that doesn’t work.

  7. So I’m another with the file upload problem….WPMU 2.9.2 on a Plesk server. The blogs.dir has the correct ownership (apache) and permissions and we tried turning safe-made off. We get different error messages, I get “Unable to create directory domainxxx.com/httpdocs/wp-content/blogs.dir/1/files. Is its parent directory writable by the server?” The answer is yes, my IT guy gets a different message: “File type does not meet security guidelines. Try another. “? Any more ideas?

    1. Kathy, have you confirmed that the folder files does exist? If it does, can you try apply 777 -R onto the entire wp-contents folder?

      Since you’re IT guy is getting a different message, what kind of file is he trying to upload? Make sure the file that is being uploaded meets WPMU’s security guidelines that are listed under Dashboard > Site Admin > Options > Upload File Types. This is a list that I use: jpg jpeg png gif mp3 mov avi wmv midi mid pdf ai psd ppt pps zip xls doc docx xlsx

  8. The blogs.dir exists, wpmu can’t seem to create the subdirectory: /var/www/vhosts/mydomain.com/wp-content/blogs.dir/2/files/2010/03 etc.
    I get the same error message with the wp-content permission set to 777
    I have checked the file types allowed for upload.

Leave a Reply

Your email address will not be published. Required fields are marked *