in reply to Writing binary data directly to webpage
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Writing binary data directly to webpage
by ttcuberat (Sexton) on Sep 30, 2003 at 15:36 UTC |