如何使用Perl CGI脚本提供图像?
发布时间:2020-12-15 21:16:51 所属栏目:大数据 来源:网络整理
导读:我的Google fu让我失望了.如何使用Perl提供已生成的图像? 例: htmlbodyimg src="getimage.pl"/body/html getimage.pl里有什么? 解决方法 干得好: #!/usr/bin/perl -wmy $file = "inner-nav.gif";my $length = (stat($file)) [10];print "Content-type: i
我的Google fu让我失望了.如何使用Perl提供已生成的图像?
例: <html><body><img src="getimage.pl"></body></html> getimage.pl里有什么? 解决方法
干得好:
#!/usr/bin/perl -w my $file = "inner-nav.gif"; my $length = (stat($file)) [10]; print "Content-type: image/gifn"; print "Content-length: $length nn"; binmode STDOUT; open (FH,'<',$file) || die "Could not open $file: $!"; my $buffer = ""; while (read(FH,$buffer,10240)) { print $buffer; } close(FH); (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |