in reply to To display images using CGI

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