Great Templates

FEATURED WEB TEMPLATES

Amazon Books

Learn PHP

PHP Training
Zend Cert Training Zend Certified Engineer Zend PHP Pro

Perl: How To Display Images (binary Data) From A Perl CGI

You can output almost any sort of data using the
" Content-type: tag."
eg :-
#!/usr/bin/perl -w
my $file = "Schogini7kAdobe1.gif";
my $length = (stat($file)) [10];
open (FH,"<$file") || die "Could not open $file: $!";
@data = ;
print "Content-type: image/gif\n";
print "Content-length: $length \n\n";
print @data;
close(FH);
Note :
The "stat" function will return the file info like File mode, device no, total size etc; "$length" variable has the file size.

"<" sing means Open the file for Reading only.

*Note: File must have an ".cgi" extension.
 


Learn PHP | Zend Certified Engineer | Zend PHP Pro | PHP Web Apps | Web Hosting Service | Low Cost Domain Names | Great Templates | Great Books | Testimonials | Tech.Articles | TOS | AUS | Home | Linux Apache MySQL PHP