如何使用Perl CGI脚本提供图像? [英] How can I serve an image with a Perl CGI script?
本文介绍了如何使用Perl CGI脚本提供图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的Google fu让我失望了。如何使用Perl提供已生成的图像?
My Google fu is failing me. How do I use Perl to serve up an already generated image?
示例:
<html><body><img src="getimage.pl"></body></html>
getimage.pl中包含什么内容?
What goes in getimage.pl?
推荐答案
在这里:
#!/usr/bin/perl -w
my $file = "inner-nav.gif";
my $length = (stat($file)) [10];
print "Content-type: image/gif\n";
print "Content-length: $length \n\n";
binmode STDOUT;
open (FH,'<', $file) || die "Could not open $file: $!";
my $buffer = "";
while (read(FH, $buffer, 10240)) {
print $buffer;
}
close(FH);
这篇关于如何使用Perl CGI脚本提供图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文