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


In reply to Image on web page by daynite

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.