Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Sep 2004
    Location
    USA
    Posts
    314
    Thanks
    7
    Thanked 0 Times in 0 Posts

    Storing files by upload date

    I have several thousand files that were uploaded to my site that are all stored in one big folder. I'd like to separate them out into folders by date. Each upload has a mysql row associated with it that includes the upload date/time, so I can write a script to go through and move them into appropriate folders. My question is, how would I make sure that these files are still accessible through their old/original URLs?

    For example, right now a file might be located at http://example.com/files/abcdef.png and after I move it, it would be located at something like http://example.com/files/2013/02/14/abcdef.png how would I make the original URL load this file? Would there need to be a mysql query each time a file is loaded to determine where it is stored?

  • #2
    Senior Coder
    Join Date
    Sep 2010
    Posts
    2,178
    Thanks
    15
    Thanked 253 Times in 253 Posts
    Quote Originally Posted by Riboflavin View Post
    I have several thousand files that were uploaded to my site that are all stored in one big folder. I'd like to separate them out into folders by date. Each upload has a mysql row associated with it that includes the upload date/time, so I can write a script to go through and move them into appropriate folders. My question is, how would I make sure that these files are still accessible through their old/original URLs?

    For example, right now a file might be located at http://example.com/files/abcdef.png and after I move it, it would be located at something like http://example.com/files/2013/02/14/abcdef.png how would I make the original URL load this file? Would there need to be a mysql query each time a file is loaded to determine where it is stored?
    What advantage do you get by actually moving them, or copying them to a folder ? Why not just use the database to make up text files that list the uploaded files by the date ? Then if someone needs to access a file by date they wouldn't have to search the whole database to find them. And you wouldn't have to move them. You could periodically update those listings.
    Welcome to http://www.myphotowizard.net

    where you can edit images, make a photo calendar, add text to images, and do much more.


    When you know what you're doing it's called Engineering, when you don't know, it's called Research and Development. And you can always charge more for Research and Development.

  • #3
    Regular Coder
    Join Date
    Sep 2004
    Location
    USA
    Posts
    314
    Thanks
    7
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by DrDOS View Post
    What advantage do you get by actually moving them, or copying them to a folder ? Why not just use the database to make up text files that list the uploaded files by the date ? Then if someone needs to access a file by date they wouldn't have to search the whole database to find them. And you wouldn't have to move them. You could periodically update those listings.
    I guess I didn't explain myself very well, the site is pretty heavily used by a lot of people as a file host. It is well over million files and it just isn't reasonable to keep them all in one folder, it is slowing things down as you can imagine.

  • #4
    Senior Coder
    Join Date
    Sep 2010
    Posts
    2,178
    Thanks
    15
    Thanked 253 Times in 253 Posts
    Quote Originally Posted by Riboflavin View Post
    I guess I didn't explain myself very well, the site is pretty heavily used by a lot of people as a file host. It is well over million files and it just isn't reasonable to keep them all in one folder, it is slowing things down as you can imagine.
    Yes, there's quite a difference between several thousand and several million, and putting them in different folders is a good idea. I would still make up listings by date and use those as a basis for copying the files to the folders, then turn them around and use them for finding the files in the folders. All done very carefully..
    Welcome to http://www.myphotowizard.net

    where you can edit images, make a photo calendar, add text to images, and do much more.


    When you know what you're doing it's called Engineering, when you don't know, it's called Research and Development. And you can always charge more for Research and Development.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •