You haven't really given enough data to be sure, but here's my guess at what is happening.

Your CGI program and the image are both in the /cgi-bin directory on your web server. Your web server is almost certainly configured to treat all requests for content within cgi-bin as a request for executable content. Therefore here's what happens:

  1. Browser requests /cgi-bin/your-program
  2. Your program returns your HTML, but that includes a reference to logo.jpg. This is a relative URL so the browser requests it from the same place as the current page
  3. Therefore the browser requests /cgi-bin/logo.jpg
  4. As this request is for a resource in cgi-bin the web server tries to execute the file (logo.jpg) and return the output to the browser (in exactly the same way as it does for any CGI request)
  5. As logo.jpg is not an executable file, the operating system returns an error when the web server tries to execute it
  6. The web server therefore returns a 500 error to the browser, but as this isn't the main request for the page the browser just puts a "broken image" placeholder on the page.

If this is the case, there are a few lessons you can learn:

  1. Only executable files go in the cgi-bin directory. Static content goes elsewhere in the directory tree
  2. Checking the web server access log would have shown you the requests that were being made
  3. Checking the error log would have shown you the error that the web server got when trying to execute the image file.
--
<http://dave.org.uk>

"The first rule of Perl club is you do not talk about Perl club."
-- Chip Salzenberg


In reply to Re: To display images using CGI by davorg
in thread To display images using CGI by Anonymous Monk

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.