Hi All, Thanks for the help with the last problem, I got another one I have been thinking about for a while, and can't come up with a good solution. Essentially it is how to organize up to tens of thousands of files in folders, so there isn't too many files in one folder, but the database knows where the files are, currently the situation is like this:
3 files, dogs.jpg, cats.jpg and birds.jpg get put in the "uploaded" folder, and 3 database records get written: id | gallery_id | filename 1 1 dogs.jpg 2 1 cats.jpg 3 1 birds.jpg The when the gallery with an id of one gets displayed, the images resized/dogs_600_800.jpg, resized/cats_600_800.jpg, resized/ birds_600_800.jpg get made (800 by 600 are the max width and height settings for gallery 1). I also want to have a "copy gallery" function, which adds a row to the gallery table that is a duplicate of gallery 1, except it is called "copy of gallery 1" and has a new id. The copy gallery function would do this to the image table: id | gallery_id | filename 1 1 dogs.jpg 2 1 cats.jpg 3 1 birds.jpg 4 2 dogs.jpg 5 2 cats.jpg 6 2 birds.jpg Now I could change the width and height of gallery 2 to 400 and 300, and when gallery 2 gets viewed, resized/dogs_300_400.jpg, resized/ cats_300_400.jpg, resized/birds_300_400.jpg get made. This all works great, until 10,000 images are added, and the 'uploaded' and 'resized' get so big they are not manageable if you want to ftp and find an image, and they will eventually slow the server down. Possible solutions I have so far: 1.)Make folders based on the first letter/number of the filename, splits the files into 36 folders (or 36x36 if first and second character).This is good as any row in the database knows where the uploaded file is (when it makes resized images), because it knows the filename. Downside: someone uploads thousands of images from a camera that lables the images dsc_0001, dsc_0002, dsc_0003.... 2.)Make folders based on id in database. (eg 0-100 folder, 101-200 folder). Good side, keeps right amount of images in folder. Downside, when you copy a gallery, the new records don't know where to look for the uploaded image. 3.)For every upload, check the size of the latest folder, and if it is too big, make a new folder. For every database record write the path of the image including the folder and file path. When image records are copied, this full path will get copied too. Downside, a lot of time working out the latest folder, and size of the folder each time you upload a file. Does anyone have any smarter ideas on how to organize the files? Thanks, Matt.
-- NZ PHP Users Group: http://groups.google.com/group/nzphpug To post, send email to [email protected] To unsubscribe, send email to [email protected]
