7.1. Design of the Online Photo Album

The photo album site could have a database-driven backend; each album would be assigned a unique ID and saved in some table. Perhaps another table would correlate images to the appropriate album. However, the file system is a natural choice to keep things organized so a database solution complicates the project more than it really needs to be. Each directory will represent a photo album and the files stored within it the associated pictures. Creating an album is now as simple as creating a directory and uploading files — something you did in the previous chapter!

The File Upload utility you created in the previous chapter can serve as an excellent back end to create and manage albums. The base directory holding all albums can be stored either outside or within a web accessible directory; it's a matter of preference if you want the original images to be accessible only through the album application or not. I've chosen to store mine outside the web root.

Some may argue this isn't a good idea as files stored outside the publically accessible directory must be filtered through PHP and causes additional overhead or is a pain when image sizes become too large. By moving these files to a public location this additional overhead is eliminated. However, with the images outside the public area you are able to implement filtering the requests to allow bandwidth throttling, referrer checking as a leeching deterrent, and so on. So it really does just boil ...

Get PHP and MySQL®: Create-Modify-Reuse now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.