Imagine photobucket/imageshack, you can register and upload photos. I'm making something similar - but with a different objective. I had this before, each user had a folder which the files were dropped into, for example - here are 3 user's with one photo
http://www.website.com/images/Bob/my...01-23-2008.jpg
http://www.website.com/images/Jack/m...01-24-2008.jpg
http://www.website.com/images/Tom/my...01-22-2008.jpg
Then, for the gallery, each time a thumbnail is requested it will be created if not already. If nobody visits your gallery, and you go there, you have to wait for the page to load. I fixed this by automatically doing the thumbnail when you upload... Another performance issue I thought of, I didn't use a database at all. Whenever they request the page, I used a loop to get a list of all the images in the folder and sort by date, then pagination (i think is the term) to show 20 per page. Each page would do this, you could imagine if the server had many visitors this would be a huge waste of performance.
Is there a more efficient way of doing this? I was thinking of a MySQL database to associate different files with different users.
I thought about uploading them to a generic "/images" folder, and add the URL to the MySQL db and put file information there (Filename, size, date, resolution etc). But then it would seem each user needs a separate mysql table. Is this efficient?
Or, I could do the same as above but make ALL images go into the same table, and add the user who owns the image. There is less wasted tables but then there is one huge table - once this reaches a certain size, could I expect performance issues?
What other ways can this be done? How should I handle the thumbnails? What about adding a title/description/tags etc to the image?
|