in reply to Image content help
The HTML page:
#!perl -w $| = 1; use strict; use CGI; my $CGI = CGI->new(); print $CGI->header('text/html'), <<'END_HTML'; <html> <head> <title>Sample Image Page</title> </head> <body> <img src="test.cgi" /> </body> </html> END_HTML
The perl script for the image (note that using read() is preferable compared to reading line-by-line when handling binary data such as images, as you may be pushing a lot of data into memory when you don't want to):
#!perl -w $| = 1; use strict; use CGI; my $CGI = CGI->new(); print $CGI->header('image/gif'); open( my $img, '<', 'packplan.gif' ) or die("open failed: $!"); binmode($img); binmode(STDOUT); while ( read($img, my $buf, 1024) ) { print $buf; } close($img) or die("close failed: $!");
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Image content help
by Mercio (Scribe) on Jun 17, 2004 at 17:00 UTC | |
by saskaqueer (Friar) on Jun 18, 2004 at 05:49 UTC |