This is a discussion on Re: how to show an image from database within the alt.comp.lang.php forums, part of the PHP Programming Forums category; Carina wrote: > I'm trying to show an image that I'm getting from the database. I'm able ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Carina wrote:
> I'm trying to show an image that I'm getting from the database. I'm able to > get the instructions for the pictures. But I need to get it into an image > and show it in HTML. > > Carina I don't know if you can do it in PHP but what you want to do is write a separate page where you set the MIME type of the page to image/gif (or whatever)* and then write out the bytes of the image (assuming it is the image you have stored in the db and not just its name/location) then you can reference this from other pages like: <img src="/image.php?db_id=324" /> And that gets image 324 from the db. And of course the db_id can be dynamically generated in the non-image PHP page or even in the image one if you pass in criteria. Does that make sense? T * = I'm being a bit vague here because I'm not sure exactly what you do in PHP. There's probably some kind of ResponseType method on the Response object (if there is such a thing in PHP!) |