Re: <img> tag does not work in my perl/cgi code
by ikegami (Patriarch) on Feb 23, 2008 at 21:11 UTC
|
| [reply] [d/l] [select] |
|
Yes, exactly there. Besides, when I get source from my web page where image is not shown, save as HTML file, place it in /cgi-bin/ directory it opens with image. Why?
| [reply] |
|
vit, webservers are not usually configured to render images in a CGI/executable mapped directory. The only thing that happens to files residing in these trees is that they are executed (ie. scripts etc.) Images and HTML docs should never reside in this tree.
Images, HTML documents, etc., should reside in the non-executable side of the webserver which is mapped so that the content is merely displayed (and *NOT* executed). This tree is usually named "htdocs" (in the Unix world, in MS-IIS it's named something else).
If you view the files statically (ie. via your filesystem), the configured limitations of the webserver mappings are not imposed, thus you can view the image successfully.
Your wish is my commandline.
| [reply] |
Re: <img> tag does not work in my perl/cgi code
by jkva (Chaplain) on Feb 23, 2008 at 21:49 UTC
|
Just a wild guess... but I'd say your webserver is configured to treat files in /cgi-bin as scripts and can therefore not show it. But I might be completely wrong. In any case, cgi-bin is for scripts, not for images. Those belong in another folder , depending on your webserver's configuration.
Best of luck! | [reply] |
|
Thanks, it's a good guess, I will try to see the server configuration. The only thing is that I store other files like click count and others under /cgi-bin/ and all of them work. Could you comment this.
| [reply] |
|
It really depends on which program is in control when you are trying to look up /images/image.png. Sometimes /images/image.png is a URL, and sometimes it is a file path, and the two are most definately different, even though they look the same.
Apache handles this internally, using a complex set of rules. /cgi-bin/ is one of these rules. Instead of looking in /var/www/cgi-bin/, Apache looks in /usr/lib/cgi-bin/ (under Debian). /images/ can be remapped in Apache too, perhaps leading to /var/images or something like that.
However once your perl script has started, path lookups are handled as normal Unix path lookups (using the system PATH variable, plus any changes depending on the users settings).
This is confusing, difficult, undocumented and something you have to learn when dealing with Unix. Or any operating system really. Web services are a confusing mash of programs, and figuring out which one has control at the critical moment is a big part of figuring out the bugs.
___________________
Jeremy
Insight is found at the bottom of the cup.
| [reply] |
|
Dear Guys,
I'm New to PERL, I'm trying to create a webpage with a Logo in PERL+CGI.
I'm also facing the same problem.
If you solved this, please share the information to help me.
Here is my code:
#!C:/Perl/bin/perl.exe
use CGI;
$q = new CGI;
print "Content-type:text/html\n\n";
print '<HTML>
<head></head>
<body>
<h1>
<img alt="LOGO" src="LOGO.gif" alt="LOGO"/>
My Name is SaRaVaNaN.
</h1>
</body>
</HTML>';
The HTML Styles are loading perfectly, & a 'X' box is showing instead of the image.
| [reply] [d/l] |
|
Re: <img> tag does not work in my perl/cgi code
by proceng (Scribe) on Feb 24, 2008 at 00:40 UTC
|
if you change:
<img src="images/image.jpg" alt="site_image" width="800" height="200">
to:
<img src="/images/image.jpg" alt="site_image" width="800" height="200">
(note the / before images) and store image.jpg in a images directory under your configured web root drive (on my lighttpd configuration it is:
server.document-root = "/usr/local/var/www/"
so image.jpg would have a real location of /usr/local/var/www/images/image.jpg) you should find that it works. | [reply] |