Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> displaying Jpg BLOB in Web browser using PL/SQL
Hi folks.
We've loaded a JPG image into a Blob in our database, and we want to retrieve it, and display it in the user's Web browser, using a PL/SQL procedure. We've used Tom Kyte's image_get procedure, and changed the mime header for JPEG files. However, the procedure doesn't work - we get a broken image link as a result.
We know the image was loaded correctly into the database. A Perl script can fetch it, and we've confirmed through visual inspection and through a checksum that the image is the same as the original. I tried right-clicking the broken image link and saving it as a local file, and the image is corrupted.
Here is the image_get package body:
CREATE OR REPLACE package body insitu.image_get AS
procedure jpg (p_id in images.no_image%type) AS
s_image blob; l_amt number default 30; l_off number default 1; l_raw raw(4096);
BEGIN SELECT fichier_image INTO s_image FROM images WHERE no_image = p_id;
owa_util.mime_header( 'image/jpeg' );
begin
LOOP
dbms_lob.read(s_image, l_amt, l_off, l_raw);
htp.prn( utl_raw.cast_to_varchar2( l_raw ));
l_off := l_off + l_amt;
l_amt := 4096;
END LOOP;
EXCEPTION
when no_data_found then
NULL;
end;
end;
end;
/
The procedure is called in another PL/SQL procedure, that displays the complementary information.
htp.print(' <TD ALIGN="Center" COLSPAN-"4"><IMG SRC="/pls/invivo/insitu.image_get.jpg?p_id=' || pNo_Image || '"></TD>');
We're thinking that this might be a mime problem, but we can't quite figure it out. Does anybody have any ideas that might help?
Thanks a lot!
-- Benoit Hebert Assistant de Recherche - Bioinformatique Research Assistant - Bioinformatics Centre Hospitalier de l'Universite LavalReceived on Mon Jun 17 2002 - 15:54:03 CDT