The MU forums have moved to WordPress.org

Change Upload Directory in blogs.dir (22 posts)

  1. jesper2000
    Member
    Posted 17 years ago #

    In a prior installation of WPMU, one was given the option of sorting uploaded files into a neat calendar-based folder logic, in the blogs.dir directory, e.g. blogs.dir/1/files/2006/09/file.jpg or just into a "files" folder. The latter is what I want on my current installation (that doesn't give me that option), so that all uploaded files are just (and always) dropped into e.g. /blogs.dir/1/files/.

    I've tried deleting

    if ( get_settings('uploads_use_yearmonth_folders')) {
    // Generate the yearly and monthly dirs
    $time = current_time( 'mysql' );
    $y = substr( $time, 0, 4 );
    $m = substr( $time, 5, 2 );
    $dir = $dir . "/$y/$m";
    $url = $url . "/$y/$m";
    }

    from line 920 in wp-includes/functions.php - but to no avail.

    Can anyone help me?

  2. jesper2000
    Member
    Posted 17 years ago #

    What gives?

  3. andrea_r
    Moderator
    Posted 17 years ago #

    Dunno. I'm using RC4, and it's behaving like it should.

  4. muhkayoh
    Member
    Posted 17 years ago #

    jesper2000: I had the same need and was able to get what I wanted by commenting out the appending part of the last two lines in that code:

    $dir = $dir; // . "/$y/$m";
    $url = $url; // . "/$y/$m";

    I'd rather have the ability to set the path via admin, but that functionality seems to be missing from my installation as well.

  5. dsader
    Member
    Posted 17 years ago #

    I found a wp-admin/options-misc.php from a normal version of wordpress and uploaded it into mu. (I commented out all but the lines that enable the monthly file organization.)

    Un-comment the link to options-misc.php in mu's wp-admin/menu.php.

    Got to Dashboard-->Options-->Upload Options.

    One Click.

    No more dated folders.

    Now all your mu-users can click to enable/disable dated folders.

  6. suleiman
    Member
    Posted 17 years ago #

    dsader, that seems pretty cool, but it's rough asking everyone to go to their options page and configure their upload folder.

    muhkayoh, does the hack you have change it for all blogs or only the admin blog?

  7. helmi
    Member
    Posted 17 years ago #

    jesper, i'm a bit curious about why you want it this way? Is there any special reason? I think the dated folders are a good first step for avoiding problems with the uploads (too many files in one directory are always a problem). I wish twe also could have a more complex structure for user directories or we will run into the same problems with the first level (user ids).

  8. muhkayoh
    Member
    Posted 17 years ago #

    suleiman, it changes it for all blogs.

  9. suleiman
    Member
    Posted 17 years ago #

    okay, modifications made.

    What would be nice would be the ability to have the folders set based on the username of the blogger. It's simple and makes good sense methinks

  10. VentureMaker
    Member
    Posted 15 years ago #

    Well, sorry to bump an old thread...

    I need to disable dated folders for uploads - I want everything to be in just a "files" folder in blogs.dir/<blogid>

    What exactly should I do?

  11. VentureMaker
    Member
    Posted 15 years ago #

    Well, sorry to bump an old thread...

    I need to disable dated folders for uploads - I want everything to be in just a "files" folder in blogs.dir/<blogid>

    What exactly should I do?

  12. josephd
    Member
    Posted 15 years ago #

    My site has over 3000 blogs and I think it will be difficult to manage the upload dir when the number of blogs grows to a higher level. Is there any better way to arrange the upload files and improve the scalability?

  13. andrea_r
    Moderator
    Posted 15 years ago #

    32,768 is the magic number where you'll run into issues becasue that's the maximum number of subdirectories allowed under Linux.

    Since wp.com clearly has more than that and still uses the same structure, look into setting up another box when you get more blogs.

  14. VentureMaker
    Member
    Posted 15 years ago #

    OK, andrea, still what about making all files appear in blogs.dir/<blogid>/files and not in blogs.dir/<blogid>/files/<year>/<month>, etc?

  15. mccay_a
    Member
    Posted 15 years ago #

    Bump

    I have a specific need for all files to upload to a single folder, i have a media player that plays mp3 files located in a single folder.

    Cant it be hard coded to point all uploads in one directory, or is there and option in the config under sites to point to the same folder as main site

    Regards, Alan

  16. tdjcbe
    Member
    Posted 15 years ago #

    All files? Gotta admit that's probably not going to work as you;re going to have clients naming their files the same thing and causing overwrites like crazy.

  17. mccay_a
    Member
    Posted 15 years ago #

    Not the case, i am not doin a lare scale deployment. only 5 users and thre is no chnace based on content that files will be named the same

    I ahve been searchin for a lon time for and answer, any help woudl be appreciated

    Regards, Alan

  18. tdjcbe
    Member
    Posted 15 years ago #

    I seem to remember a flat level directory setting within Dashboard -> Site Admin -> Blogs -> Edit Blog that you can set for each and every blog manually. If it's blogs that still have to be created, take a look at the defaults in wp-admin/includes/schema.php for it. It;s actually a standard setting within regular wordpress that I'm sure has been carried over.

    You're still going to have to create the subdirectories within blogs.dir though and set them as writable by the webserver.

  19. andrea_r
    Moderator
    Posted 15 years ago #

    "I seem to remember a flat level directory setting within Dashboard -> Site Admin -> Blogs -> Edit Blog that you can set for each and every blog manually."

    Yep, that's definitely there.

  20. tdjcbe
    Member
    Posted 15 years ago #

    Thanks. One of those 80 tabs open at a time situations and couldn't open up yet another tab without losing this one.

  21. mccay_a
    Member
    Posted 15 years ago #

    Ok, changing this location does not work

    So i change the path from
    wp-content/blogs.dir/1/files
    to
    wp-content/blogs.dir/files

    I created this folder and changed the permission to allow write access.

    But when ever i upload a file it still goes into the old folder of wp-content/blogs.dir/1/files

    Any thoughts

    Regards, Alan

  22. mccay_a
    Member
    Posted 15 years ago #

    Ok Solved it. Pretty simple, wonder why no one told me this

    I just edited wp-settings.php

    found following line and changed location to my custom location
    ---------------------------------------------------------
    if( !defined( "UPLOADS" ) )
    define( "UPLOADS", "HOME/WP-CONTENT/UPLOADS/" );
    ---------------------------------------------------------

    where home is folder just under root and wp-content/upoads is location of my old file repository from old wordpress install

    Regards, Alan

About this Topic

  • Started 17 years ago by jesper2000
  • Latest reply from mccay_a