Sure, that's not bad. Generate image tags that are actually calls to another program:
<img src="fetch_image.cgi?image=puppy.png" />Within fetch_image.cgi, read the image from the database, set the appropriate headers, and print the image:
use CGI; use DBI; my $q = CGI->new(); my $name = $q->param( 'image' ); my $dbh = DBI->connect( 'some', 'connection', 'options' ); my $sth = $dbh->prepare(<<END_SQL); SELECT content_type, image FROM images WHERE image_name = ? END_SQL $sth->execute( $name ); my ($type, $image) = $sth->fetchrow_array(); print $q->header( $type ), $image;
Database connecting and error checking are left as an exercise for the reader.
In reply to Re: Writing binary data directly to webpage
by chromatic
in thread Writing binary data directly to webpage
by ttcuberat
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |