Image databasing / storing

Discussion in 'PHP' started by smatts9, Jul 19, 2006.

  1. #1
    I have a site, and I am going to put up an image upload script for my members. When saving images to the server would it be better to make separate directories such as:

    site.com/images/ user's unique id / photoid.extension

    or just

    site.com/images/userid_photoid.ext

    both would create unique filenames so I wouldn't have a problem there, but wondering which is faster and better?
     
    smatts9, Jul 19, 2006 IP
  2. JBauer

    JBauer Guest

    Messages:
    10
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    The userid_photoid.ext option would be one less folder write and could potentially be faster. I think both are fine as they are unique file names. I prefer the folder approach, as it's easier to navigate the file structure and delete the files later.

    You can always go back and test each approach out with timers if you think one will outperform the other.
     
    JBauer, Jul 19, 2006 IP
  3. DrMalloc

    DrMalloc Peon

    Messages:
    130
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Depending on the server configuration, i've known some operating systems/languages to complain when having to read directories full of huge quantities of files.
     
    DrMalloc, Jul 19, 2006 IP
  4. coderlinks

    coderlinks Peon

    Messages:
    282
    Likes Received:
    19
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Hi,
    If you make it in the userid_photoid format, it will be hell to delete one user (for uploading pr0n maybe ;) :D ) . If you make it as folders, you can just delete the corresponding folder.

    Thats just my 2c.

    Thomas
     
    coderlinks, Jul 21, 2006 IP
  5. Koncept

    Koncept Peon

    Messages:
    50
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Each user should have his own folder.
     
    Koncept, Jul 21, 2006 IP
  6. ccoonen

    ccoonen Well-Known Member

    Messages:
    1,606
    Likes Received:
    71
    Best Answers:
    0
    Trophy Points:
    160
    #6
    yes, never have a GIGANTIC folder of images. Seek time would be huge.... but if they are seperated per user, and even seperated furhter beyond that - it would be best.
     
    ccoonen, Jul 22, 2006 IP
  7. wwm

    wwm Peon

    Messages:
    308
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #7
    mysql 5 is quite good a storing Large binary objects, and seek times are great for large databases (mine is well over 10gb now for one particular image upload site) heck thats what databases were designed for

    at first i was sceptical that mysql cant handle so much data and was storing in folders,

    but mysql 5 proved to be very very good and capable, also using php5s PDO extension is handy for easily and efficiently reading and writing large amounts of data
     
    wwm, Jul 23, 2006 IP