How to display uploaded images in a web page?

Gaston

Member
I have developed some web applications using PL/SQL Developer and the Oracle HTP/HTF ToolKit;
I have stored images files in Oracle tables using PL/SQL Developer and I now want to display those stored images in a web page. Does anyone know how to do this? Thanks
 
You could try this block of code:

Code:
CREATE OR REPLACE PACKAGE display$image
IS
  PROCEDURE gif(
    p_image_pk                     IN      images.image_pk%TYPE );

  PROCEDURE test_image;
END display$image;
/
CREATE OR REPLACE PACKAGE BODY display$image
IS
  PROCEDURE gif(
    p_image_pk                     IN      images.image_pk%TYPE )
  IS
    l_img_blob                               BLOB;
  BEGIN
    OWA_UTIL.mime_header( 'image/gif', FALSE );

    SELECT image_blob
      INTO l_img_blob
      FROM images
     WHERE blb_seq = p_image_pk;

    HTP.p( 'Content-Length: ' || DBMS_LOB.getlength( l_img_blob ));
    HTP.p( 'Expires: Thu, 29 Oct 2000 17:04:19 GMT' );
    HTP.p( 'Pragma: no-cache' );
    HTP.p( 'Cache-Control: no-cache' );
    OWA_UTIL.http_header_close;
    wpg_docload.download_file( l_img_blob );
  END;

  PROCEDURE test_image
  IS
  BEGIN
    HTP.htmlopen;
    HTP.bodyopen;
    HTP.tableopen( cborder => 1 );
    HTP.tablerowopen;
    HTP.p( cbuf => '[TD]<img src=display$image.gif?p_image_pk=1279>' );
    HTP.p( cbuf => '[/TD]' );
    HTP.tablerowclose;
    HTP.tableclose;
    HTP.bodyclose;
    HTP.htmlclose;
  END;

END display$image;
I haven't tested this particular piece of code, but I took it from a working package we use at our company.
I found this somewhere in the Ask Tom archives (I believe) (credit where credit is due).

Hope it works,
Regards,
Patrick
 
Back
Top