Images from DB

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • José Checa Claudel

    #1

    Images from DB

    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">

    <?php
    include("proced ures/function.php");

    $prevImageStore d = dummy(1);
    echo "<img src='$prevImage Stored'>";
    ?>

    </td>
    </tr>
    </table>

    Any idea. Thanks in advance. Pepe.-

  • Mike Willbanks

    #2
    Re: Images from DB

    José Checa,[color=blue]
    > 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:
    >
    > Any idea. Thanks in advance. Pepe.-
    >[/color]

    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:
    image.php
    $conn = oci_logon();
    $stmt = oci_parse($conn , 'select image_blob from images where image_id =
    :image_id');
    $image_id = (int) $_GET['image_id'];
    oci_bind_by_nam e($stmt, ':image_id', $image_id);
    oci_execute($st mt);
    $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

    Comment

    Working...