Here's an interesting challenge: I'm writing an app that keeps a lot of JPGs and serves them up to users when they have the proper access. Some users will have some access to some of the JPGs sometimes... so I can't just dump all the graphics in a directory and give out the URLs; then anyone could link to them.
I'm thinking about how I want to "serve" (or I should say, "manage the serving") of the graphics via PHP. Some ideas:
Keep them in a database and serve them on the fly. Pro: secure, Con: a hassle, not easy to manage the image files without doing db calls, more overhead
Keep them in a directory that the web server can't get to, then when a graphic is needed, copy it to a temp directory available via http, with a randomized unique filename. Set an expiry date and delete them from the public directory after a given length of time. Pro: easy to understand, Con: disk overhead, processor overhead, still small potential for URL sharing.
Read the graphic into a PHP variable and spit it back out on the fly, like sucking it from the db but pulling it from the disk file instead. Pro: easy to understand, Con: processor overhead.
Anyhow, you get the idea... what do y'all think? I'm leaning towards #3 right now.
best,
Eric