Hi,

In order to create and image based web counter using Perl cgi on Windows 98 I am just trying to read an image into an html from a perl cgi script. But it does not work for some reason. I have 3 files in my source directory. mycounter.html, mycounter.cgi and counter.jpg Inside my html file mycounter.html I try to read image from the perl cgi script using the line.

<img src = mycounter.cgi>

where mycounter.cgi is my perl cgi program with the following contents.

#!C:\Progra~1\Perl\bin\perl use CGI; $co=new CGI; $size = stat("counter.jpg")[7]; open (FILEHANDLE,"<counter.jpg"); read FILEHANDLE,$imagedata,$size; close FILEHANDLE print $co->header(-type=>'image/jpeg'), "Below is my counter image file", $imagedata;

Then I try to open mycounter.html from the browser. But all I see on the browser is the string "Below is my counter image file" which it reads from the perl script but then there is no image at all (just a blank image). Why is the html unable to read the image sent from the cgi script. Once again I am running this on Windows 98 OS. Your help will be greatly apprecited
thanks grao5 (grao5@hotmail.com)


In reply to Error reading image from perl cgi script into HTML by grao5

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.