Dear monks, it's 12:30am here and I am having a "brain fart". I couldn't work out why the CGI script below does not display the image properly. Basically I want the CGI script to push a jpeg image to the web browser. But when I run it from the browser, the IE6 browser just 'hangs', I can see it's waiting for something. The script works when invoked from command-line though, I can see the content-type header and the image that follows. Can someone please help me to spot what's going wrong in my script? Thanks a lot in advance.
#!E:/Perl/bin/perl.exe -w use strict; use Bytes; use CGI; my $cgi = new CGI; #my $cgi_cust = $cgi->param("cust"); #my $cgi_bill = $cgi->param("bill"); my $cgi_cust = "Telstra"; my $cgi_bill = "telstra-2003-07-28.jpg"; die unless defined $cgi_cust && defined $cgi_bill; my $root = "E:/appdoc/Internet Banking/Bills & Notices"; my $img; # load the image into memory open IMG, "<", "$root/$cgi_cust/$cgi_bill" or die; binmode IMG; seek IMG, 0, 2; my $size = tell IMG; seek IMG, 0, 0; sysread IMG,$img,$size; close IMG; if (defined $img) { binmode STDOUT; print $cgi->header( -type=>'image/jpeg'); print $img; # I think something is doggy here } else { print $cgi->header, "<HTML><BODY><P>IMAGE NOT FOUND</P></BODY></HT +ML>\n"; }

In reply to Image display problem with CGI script by Roger

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.