This is a discussion on Displaying an image from a database within the PHP General forums, part of the PHP Programming Forums category; I have created a content management system for a web site and want some help with the most efficient way ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
I have created a content management system for a web site and want
some help with the most efficient way to display images that are stored in a database. The way, it seems, that php displays images in a web page is with a link to a php "image" file with an image header and script which displays the image. The the src of an <img> tag points to that file and obtains the image for display on a web page. I have several database tables containing records with images that need to be displayed on various web pages. At present, I have a separate image file for each database. I obtain an image from each table by sending the record key to that file with a GET. The "image" file then retrieves the image from the table it is associated with using that key obtained via the GET and displays it. This requires me to have a separate file for each table in the database from which I retrieve images. I'd like to simplify this, obtaining images from all tables with only one "image" file, rather than one for each table. If I first retrieve the image data and send it to a generic "image" file for display, it means sending a lot of data to the file displaying the image, which is often too much for a GET. Another way I can do this is to send the appropriate query to the file in a variable which the "image" page will use to retrieve and display the image I need. I feel a bit insecure sending a valid query via a GET. Otherwise, I could sent the key, tablename, and imagefieldname via a GET that the image file assembles into a query for retrieving the image. Same issue. I keep thinking there must be a way to do this that is simpler, secure and more efficient than the one I am attempting. Can anyone help me figure out the most efficient and secure way to accomplish what I am trying to do? Thanks, --Kenoli |