Here's a small snippet from an on-line photo album that I've done that
does what you describe:
if ( $cgi->param('action') eq 'ImageGen' ) {
my $sth = $dbh->prepare(qq{
SELECT type, image
FROM photos
WHERE id = ?
});
$sth->execute( $cgi->param('id') );
my( $type, $image ) = $sth->fetchrow_array;
$sth->finish;
print "Content-type: $type\n\n";
binmode STDOUT;
print $image;
}
Now wrap that in a <IMG> tag like:
<img src=*script_name*?action=ImageGen&id=*some_id*>
...and you should be set.
Paul.
Edward J Dawson wrote:
>
> Hi,
>
> I am currently trying to get perl and mysql talking together on linux.
> I have succeeded in the basics, doing selects, inserts, updates
> and deletes when dealing with chars and ints. I have now turned
> my attention to blobs, and am having considerable difficulty.
>
> I have managed to get a blob(a jpeg file) from a local file on the
> linux box into the database, but I can't seem to get the thing back
> out and onto a webpage! I have scanned numerous lists and books,
> but seem to be unable to find any real information on dealing with
> blobs. Can anyone point me in the right direction ?
>
> Thanks very much for you time
>
> Edd Dawson