Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: MySQL: Image in a blob

by cowboy (Friar)
on Mar 29, 2005 at 00:56 UTC ( [id://443013]=note: print w/replies, xml ) Need Help??


in reply to MySQL: Image in a blob

This is a common problem I've seen made, you are most likely printing the image, into the html page, rather than using an img src tag. Try the following (assuming you're using CGI.pm)
image.html
<!-- image.html --> <img src="/cgi-bin/view_image.pl?image=123">

and view_image.pl
#!/usr/bin/perl # view_image.pl use strict; use warnings; use DBI; use CGI; my $q = CGI->new(); my $dbh = DBI->connect(....); # db setup stuff here my $sth = $dbh->prepare("SELECT image_blob FROM images WHERE image=?") +; my $result = $sth->execute($q->param('image')); if ($result && $result->rows()) { my $image_blob = $result->fetchrow_array(); print $q->header( -type => 'image/jpeg' ); print $image_blob; exit; }
Note, this code is untested, but I do something similar with images, using Mason under mod_perl

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://443013]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (3)
As of 2024-04-20 06:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found