daynite has asked for the wisdom of the Perl Monks concerning the following question:
Hi all, I have a problem with Perl-CGI script. I tried to dislay image on webpage by receiving the image name from previouse page and i'm trying
the below script, but it is not working.......
Below is the image.cgi script,
#!/usr/bin/perl
use CGI;
use CGI::Carp;
use strict;
use constant BUFFER_SIZE => 4_096;
my $q=new CGI;
my $image = $q->param("photo");
use constant IMAGE_DIRECTORY =>"/var/www/cgi-bin/images";
my $buffer="";
my( $type )= $image =~/\.(\w+)$/;
$type eq "jpg" and $type ="jpeg";
print $q->header(-type => "image/$type", -expires =>"-1y");
binmode STDOUT;
local *IMAGE;
open IMAGE, IMAGE_DIRECTORY . "/$image" or die "Cannot open $image:$!";
while ( read (IMAGE, $buffer, BUFFER_SIZE) )
{
print $buffer;
}
close IMAGE;
It is working if i declare the image name directly ($image = "imag1.gif";). any one please fix this..
20090516 Janitored by Corion: Removed italic tags, as per Writeup Formatting Tips
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Image on web page
by almut (Canon) on May 13, 2009 at 22:12 UTC | |
|
Re: Image on web page
by moritz (Cardinal) on May 13, 2009 at 22:36 UTC | |
|
Re: Image on web page
by oxone (Friar) on May 13, 2009 at 22:44 UTC |