View Single Post
Old 01-09-2013, 10:04 AM   PM User | #1
XmisterIS
Regular Coder

 
Join Date: Jun 2010
Posts: 241
Thanks: 51
Thanked 6 Times in 6 Posts
XmisterIS is an unknown quantity at this point
Best way of serving images?

I have a website which serves images in various sizes (e.g. wikipedia allows you to view the same image in different sizes). The images are uploaded by the users of the site.

Currently, I use PHP to process the uploaded images and store them in various sizes in a database (e.g. small/medium/large).

What is the best way to serve the images? I can think of:

1) retrieve each image from the database each time it is required. (*** This is the way I currently do it ***)

2) store the images as files in a folder in the public web directory and simply link to them.

3) Using the database-retrieval method, keep a store of previously-requested images in $_SESSION and serve them from $_SESSION each time they are required.

Option 2 is probably the most efficient, but I don't like the idea of having a writeable folder in the public web directory. Also, I suspect that doing this would leave the folder open to site-scrapers who could simply retrieve every image stored there.
XmisterIS is offline   Reply With Quote