Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

blob output

by bigup401 (Monk)
on Sep 10, 2018 at 22:24 UTC ( #1222100=perlquestion: print w/replies, xml ) Need Help??
bigup401 has asked for the wisdom of the Perl Monks concerning the following question:

i dont know why my pic doesn't output to page

everything is ok, coz wen i select the pic it comes ok and bring pic name. bt doesn't show on page only brings picture icon

my $pic = $DBH->prepare("SELECT PHOTO FROM tble WHERE ID = ?"); $pic->execute(#ID); $pik = $pic->fetchrow; html <img src="$pik"> output <img src="02100.JPG">

Replies are listed 'Best First'.
Re: blob output
by bliako (Chaplain) on Sep 10, 2018 at 23:17 UTC

    I think you confuse the name of the photo with its content, the "blob" as per your title.

    1. Does your DB store the filenames (of files which are stored locally) of photos which can be retrieved by ID? Then it is a matter of your perl cgi script to adjust your img src to point to that local filename given the photo ID.

    2. Does your DB contain the actual image content as a blob/binary data? Which you want your perl script to retrieve by id and then send over (the actual binary data) all the way to the client's browser and in particular to that img? Then you need something more advance for your src=. Your perl CGI script must send over the image binary data using the appropriate headers Content-type: image/jpeg...

    But I will leave you to more expert hands: read this How can I use a CGI script to return an image?

    bw, bliako

Re: blob output
by choroba (Bishop) on Sep 10, 2018 at 23:08 UTC
    Are you sure the actual JPG is stored in the directory where the server is looking for the picture (i.e. probably the same as the script is located in)?

    ($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,

      am just polling photo from db table from blob column

      the photo is stored in db not locally. as u see the example. the photo is being polled from db bt cant display i tried to use binmod

      well i think it just needs to be decoded to display coz its in encoded type

        > as u see the example

        No, the example shows the name of the file being inserted into the src attribute of an img tag:

        <img src="02100.JPG">

        You haven't posted the schema of the table nor a sample of it, so I don't know what details you keep for each photo.

        Note that

        <img src="\@\ $ome binary trash, in fact contents of a JPG file">
        doesn't display the image in the browser. The common way is to use
        <img src="data:image/jpg;base64,..."
        where you can use MIME::Base64 to encode the binary contents.

        ($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1222100]
Approved by marto
Front-paged by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (8)
As of 2018-11-12 22:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My code is most likely broken because:
















    Results (145 votes). Check out past polls.

    Notices?