Support » Networking WordPress » How to change upload directory of main site to blogs.dir

  • Resolved digitalawakening


    I’m working on a WordPress 3.0 multisite aka network install on my dev machine (OS X, MAMP stack, svn checkout from I’m confused about the differences between the upload directory for the main site of a network install, and additional sites.

    For instance, in a fresh install that I just tried, uploading an image to the main (first) site gives me a path like this:


    …and indeed, the image is in wp-content/uploads/2010/07.

    Uploading an image to an additional (the second) site gives me a path like this:


    …and of course the image is in blogs.dir/2/files/2010/07.

    What I would like to do is change the behavior of the primary/first blog to be like that of the secondary blogs – files are uploaded to blogs.dir, but the paths are the nice, more secure, rewritten /files versions. When I change the Upload Path for the primary blog (in Super Admin > Sites > Edit) to wp-content/blogs.dir/1/files, subsequent media uploads go to the proper subdirectory of blogs.dir, however the path in the uploader (and therefore the resulting img src) is not the nice rewritten /files path.

    E.g. after changing upload_dir on the primary blog, the source of an uploaded image is:

    And I would like it to be:

    Is this possible?


Viewing 10 replies - 1 through 10 (of 10 total)
  • Moderator Ipstenu (Mika Epstein)


    Lead Plugin Wrangler

    Should be. Edit the Fileupload Url to

    Poking around in the core WordPress code a bit, I can see that in wp-includes/functions.php, in the wp_upload_dir function, line 2156 is where the replacement happens – where /wp-content/blogs.dir/1/files/2010/07/image.jpg becomes /files/2010/07/image.jpg

    $url = str_replace( UPLOADS, 'files', $url );

    This is within an if statement that’s only true if it’s not the main site. What’s the reason for this?

    Hi ipstenu,

    Thanks for the reply. I tried that, but it has no effect (the behavior is the same). From some other threads in the forum I got the impression that fileupload_url isn’t used anymore.

    Edit the upload path as well? And did you copy the files over to the new spot?

    Moderator Ipstenu (Mika Epstein)


    Lead Plugin Wrangler

    digitalawakening – That may be. I changed both that AND the upload path and URL and it’s working fine for me after I moved.

    I also did an .htaccess tweak to point old images:

    # Moved Images
    RewriteRule ^wp-content/uploads/(.*)$$1 [L,R=301]

    Aha! Thank you very much, Andrea_r and ipstenu. The “Upload Url Path” option was the key. I had already moved the files over to the new spot. So, for others reading this post and wanting to accomplish the same thing, make sure you:

    1. Move the files over to the new location (or add a the RewriteRule as ipstenu did)
    2. Go to Super Admin > Sites, hover over the primary blog and click Edit
    3. Change “Upload Path” to wp-content/blogs.dir/1/files
    4. Change “Upload Url Path” to /files
    5. Change “Fileupload Url” to
    Moderator Ipstenu (Mika Epstein)


    Lead Plugin Wrangler

    I would both move the files AND apply the .htaccess fix. What my change does is say “If you come to wp-content/uploads, go over to blogs.dir instead, k’thnx’bye.”

    Hey guys, thanks for you responses to this issue. I don’t have a ton of understanding of WPMS, and I am having a similar problem.

    I want my subsite users (which are configured as subdomains) to be able to upload, but when I created a test account and tried to upload an image, it says:

    Unable to create directory /hermes/bosweb/web294/b2941/ipg.utv13/wp-content/blogs.dir/2/files/2010/08. Is its parent directory writable by the server?

    I set the permissions to 755 of blogs.dir, just like wp-content. I don’t understand though how something could upload to a subdirectory of blogs.dir, because it isn’t a folder, right?

    Another question of mine:
    Is it possible to make The Loop in my main blog spit out posts from all the blogs in my network?

    Ahhh hahah I see now. I thought ‘blogs.dir’ was supposed to be a text file. I created the directory and now it works fine.

    The second question is still up for grabs though! Thanks in advance.

    there is no loop function for that. use a plugin.

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘How to change upload directory of main site to blogs.dir’ is closed to new replies.