WordPress.org

Ready to get started?Download WordPress

Forums

Change file upload folders on WordPress 3.0 multi-site (11 posts)

  1. WPJohn
    Member
    Posted 4 years ago #

    Hello, i have a couple of WordPress 3.0 sites, in multisite mode.

    When I upload an image to the sites it puts the image in /files/2010/06/ folder (files/year/month). I would like to put them in another folder, like root or /images/. How can I change this? I simply can't find where I can change this. I hope it is possible and you can help me.

    Thanks in advance

  2. Samuel B
    moderator
    Posted 4 years ago #

    admin - settings - miscellaneous

  3. WPJohn
    Member
    Posted 4 years ago #

    Thank you
    This is strange. It looks like the miscellaneous page is gone.
    I only see writing, reading, discussion, media, privacy, permalinks (and some plugin related settings).

    I remember having this page in older WordPress versions, but in 3.0 it seems to be gone...

  4. Hubert Nguyen
    Member
    Posted 4 years ago #

    WordPressJohn, the code of options-media.php suggests that it's not enabled in multisite mode.

    <?php if ( !is_multisite() ) : ?>
    <h3><?php _e('Uploading Files'); ?></h3>
    <table class="form-table">
    <tr valign="top">
    <th scope="row"><label for="upload_path"><?php _e('Store uploads in this folder'); ?></label></th>
    <td><input name="upload_path" type="text" id="upload_path" value="<?php echo esc_attr(get_option('upload_path')); ?>" class="regular-text code" />
    <span class="description"><?php _e('Default is wp-content/uploads'); ?></span>
    </td>
    </tr>
    ...
    ...

  5. Josh
    Member
    Posted 4 years ago #

    You can get to the upload path @ Super Admin => Sites => Edit. There's a ton of stuff there.

  6. Hubert Nguyen
    Member
    Posted 4 years ago #

    jwrobbs,

    Thanks for the pointer. It turns out that while the option does not appear in Settings>Media, Super Admin>Sites>Edit has an "Uploads Use Yearmonth Folders" field that I can set to "1" (from "0"). That did it.

  7. paontheweb
    Member
    Posted 4 years ago #

    I've installed the Network feature on 3 sites on 3 different servers, all using Linux, two using Fantastico (and then upgrading the wp install) and one time using the files for WP 3.0 and creating my own databases. In each case the wp-content/uploads folder was not present causing my media uploads to seek an error page.

    It took me a while to find that you had to go to Super Admin > Options and then enable Media under Upload Settings. The warning did not appear in my Admin area at first when I clicked Media. Just thought I'd point this out to other folks.

  8. rsm08
    Member
    Posted 3 years ago #

    I digged and digged for hours and finally I found out how to take ultimate control over upload folders.

    Whenever WP is about to save an upload, it runs the wp_upload_dir() function stored in wp-includes/functions.php. This function provides a filter for changing whatever you like - including the upload directory.

    I used this to make individual per user upload folders:

    add_filter('upload_dir', 'ml_media_upload_dir');
    
    /**
     * Changes the upload directory to what we would like, instead of what WordPress likes.
     *
     *
     */
    function ml_media_upload_dir($upload) {
    	global $user_ID;
    	if ((int)$user_ID > 0) {
    		$upload['subdir'] = "/" . $user_ID;
    	}
    
    	return $upload;
    }

    Hope it can help someone!

  9. rsm08
    Member
    Posted 3 years ago #

    Sorry for posting before trying out the code .. it needed a little change for it to work:

    add_filter('upload_dir', 'ml_media_upload_dir');
    
    /**
     * Changes the upload directory to what we would like, instead of what WordPress likes.
     *
     *
     */
    function ml_media_upload_dir($upload) {
    	global $user_ID;
    	if ((int)$user_ID > 0) {
    		$upload['subdir'] = "/" . $user_ID;
    		$upload['path'] .= $upload['subdir'];
    		$upload['url'] .= $upload['subdir'];
    	}
    
    	return $upload;
    }
  10. quirico
    Member
    Posted 3 years ago #

    Hi rsm08, I'm using WP 3.0.3 in network mode and I'me experiencing a strange bug so maybe your code could be useful for me. When I uplaod a new piece of media WP returns this kind of path:
    http://domain.com/files/year/month/filename.ext which is currently accessible via browser. The problem is that WP uses a theme that relies on a 'thumbnailer' function (via thimthumb.php) that supports media only in this form:
    http://domain.com/wp-content/blogs.dir/blogID/files/year/month/filename.ext
    Do you think that function could be useful? In which file did you put your code? Thank you.

  11. gilliancs
    Member
    Posted 3 years ago #

    I can't find Super Admin>Sites>Edit now Super Admin has turned into Network Admin. Now I found it thanks to another post: go into My Sites; hover over a site you want to change and click Edit. Pick the tab at the top that you want to use.

Topic Closed

This topic has been closed to new replies.

About this Topic