Images from DB

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
Hello all.

I have a function in PHP to retreive a BLOB field in Oracle DB who has a  
JPEG image in it; but I don´t know how show it in an html page with text  
information, I have something like this, but doesn´t work properly:

<table border=0 cellPadding=15 cellSpacing=15 height=20 width="100%">
<tr WIDTH="100%" HEIGHT="100%">
    <td class="T10a" valign="top">


       $prevImageStored = dummy(1);
       echo "<img src='$prevImageStored'>";


Any idea. Thanks in advance. Pepe.-

Re: Images from DB

José Checa,
Quoted text here. Click to load it

Create a file that calls the image, outputs the header for the jpeg and  
then dumps the data in that file.  You can not just output the image  
directly into the src area ;)

Something like:
$conn = oci_logon();
$stmt = oci_parse($conn, 'select image_blob from images where image_id =  
$image_id = (int) $_GET['image_id'];
oci_bind_by_name($stmt, ':image_id', $image_id);
$row = oci_fetch_assoc($stmt);

header('Content-Type: image/jpeg');
echo $row['IMAGE_BLOB'];

Something like that, I did not check it but most of it was for php5 ;)

Mike Willbanks
Zend Certified Engineer

Site Timeline