Oracle Blob as img src in PHP page -


I have a site that currently uses images on file server images are shown on a page where The user can drag and drop everyone according to the requirement, it is done with jQuery and the images are attached to a list. Each image is very good:

  & lt; Img src = '// network_path / image.png' height = '80px' & gt;  

Now though I need to reference the stored images in an Oracle database as a blob (there is no choice on this, so eligibility is not discussed). I have no problem recovering the blob and it is being displayed using my own:

  $ sql = "Select image from images where image_id = 123"; $ Stid = oci_parse ($ conn, $ sql); Oci_execute ($ stid); $ Line = oci_fetch_array ($ stid, OCI_ASSOC + OCI_RETURN_NULLS); $ Img = $ line ['IMAGE'] - & gt; Load (); Header ("Content-Type: Image / JPEG"); Print $ img;  

But I must [skillfully] get that image as the source attribute of the IMG tag. I tried image sequencing (), but it returns the image back in the browser, ignoring other HTML I saw the data, but the IE8 size limitations are out.

So I'm stuck now. My search continues with using a source attribute that loads the second page containing the image. But I really need the image to appear on the page (note: I say the image, at least one image is the meaning, but the page is equal to eight).

Any help would be greatly appreciated.

Well, you can do a few things. You can either create a page that will render the image

  & lt; Img src = "image.php? Id = 123" />  

That image.FPP page will contain:

  $ sql = "Select image from images where image_id =". (Int) $ _GET ['id']; $ Stid = oci_parse ($ conn, $ sql); Oci_execute ($ stid); $ Line = oci_fetch_array ($ stid, OCI_ASSOC + OCI_RETURN_NULLS); If (! $ Line) {header ('position: 404 not found'); } And {$ img = $ row ['IMAGE'] - & gt; Load (); Header ("Content-Type: Image / JPEG"); Print $ img; }  

Or, you can change base 64 into symbols in src (note that not all browsers can handle this way):

  & Lt; Img src = "data: image / jpeg; base64, & lt ;? php echo base64_encode ($ img) ;? & gt;" / & gt;  

Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -