Hi,

I am trying to do a very simple thing of reading an image file (jpeg) into an HTML page from a perl cgi script. But for some reason when I click the html file I get a blank image. Why? I am running on Windows 98 OS. If someone could try this out practically and then give me details as to what is wrong in my program, I would really appreciate.

I have the following 3 files in my source directory from where I am running.

(1) myprogram.html

(2) myprogram.cgi

(3) picture.jpg

Here are the contents of my html file "myprogram.html"

<HTML> <head> <title> Test page </title> </head> <BODY> <IMG SRC = "myprogram.cgi"> </BODY> </HTML>

Following are the contents of my perl cgi program "myprogram.cgi"

#!C:\Progra~1\Perl\bin\perl use CGI; $co=new CGI; BINMODE IMAGEHANDLE1; open(IMAGEHANDLE1,"<picture.jpg") or die "filenot found"; $size1=(stat("picture.jpg"))[7]; read IMAGEHANDLE1,$data1,$size1; close IMAGEHANDLE1 ; print $co->header(-type=>'image/jpeg'), $data1;

thanks

grao5 (grao5@hotmail.com)


In reply to Problem reading image from perl cgi script 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.