Re: CGI display a gif
by ikegami (Patriarch) on Jun 06, 2005 at 15:52 UTC
|
What's the URL of the image? Relative URL "cgi-bin/images/1.gif" applied to base URL "http://localhost/cgi-bin/image.cgi" is "http://localhost/cgi-bin/cgi-bin/images/1.gif". I think you have an extra "cgi-bin/" in there. Fix: print "<IMG SRC='images/1.gif'>";
Also, how are you refering to the script? That script won't work from an <img> since it returns HTML, not an image.
| [reply] [d/l] [select] |
|
not sure if i understand ur second suggestion; wont form an <img> tag?
| [reply] |
|
The word "work" was missing. (I've just added it.) If you do <img src="http://localhost/cgi-bin/image.cgi">, you'll get a broken image since image.cgi returns HTML, yet your brower is expecting an image.
| [reply] [d/l] |
|
the properties gives the location http://localhost/cgi-bin/1.gif
| [reply] |
|
Then it's just
print "<IMG SRC='1.gif'>";
| [reply] [d/l] |
Re: CGI display a gif
by bassplayer (Monsignor) on Jun 06, 2005 at 15:56 UTC
|
I would recommend against keeping images in the cgi-bin, and place the images/ directory in the web root. You can ensure that this is accessed by changing the SRC attribute on your image tag to "/images/1.gif". The leading slash moves us out of the local directory.
| [reply] |
|
i have noticed that the properties of cgi-bin foler are read only, does this make a difference (using XP)
| [reply] |
|
the question is why does it work with html code and not cgi though? seems odd
| [reply] |
Re: CGI display a gif
by jhourcle (Prior) on Jun 06, 2005 at 16:10 UTC
|
Right click (or equivalent) on the image with a broken box, and choose 'Open Image in New Window' (or equivalent).
This will show you where the browser is trying to link to, and any error message that the server is ending to the browser.
If that wasn't useful, check your web server's error logs. (I always keep a 'tail -f' running on my error logs when debugging -- anything that shows up in there is a problem, and needs to be dealt with ... even if it's script kiddies trying to root your site, search engines looking for 'robots.txt', or obnoxious browsers looking for 'favicon.ico')
| [reply] |
|
this directs me the right location http://localhost/cgi-bin/1.gif
but reports an 500 internal server error??
| [reply] |
|
Which is what I suspected. (well, I actually expected a different URL, but I suspected the 500 error, or possibly a 403 (access forbidden, if it was trying to execute a file that didn't have execute permissions) )
To confirm that bassplayer's and my suspicions are correct, you'll want to continue with the rest of my suggestion:
If that wasn't useful, check your web server's error logs.
You really should check your webserver's error log, as there's most likely something more informative in there. (well, maybe not, as it might throw some misleading errors if it's trying to execute something that's not an executable file.)
| [reply] |
|
Perhaps it's trying to execute the image instead of rendering it. The cgi-bin/ directory is special. :-)
| [reply] |
|
Follow bassplayer's advice. Some servers treat everything in /cgi-bin (and subdirectories?) as scripts. Executing a .gif won't definitely result in a 500 error. You need to move your images outside of /cgi-bin.
| [reply] |
Re: CGI display a gif
by cool_jr256 (Acolyte) on Jun 06, 2005 at 15:53 UTC
|
if your cgi script resides in 'cgi-bin' directory this should be sufficient:
<img src='images/1.gif'>
| [reply] [d/l] |
|
tried this also with no luck?
| [reply] |
Re: CGI display a gif
by greywolf (Priest) on Jun 06, 2005 at 21:40 UTC
|
If you want to see why the HTML page does not render correctly try looking at the page source from the browser. This will reveal where the script is trying to load the image from.
| [reply] |