Reputation: 91
I hope everyone's doin good. I am facing an issue regarding the images, i have a cgi page i.e Login.cgi, in tha html section i have included some images but some are getting displayed and some are not.
Here's the code:
#!C:\perl\bin\perl.exe
use CGI::Carp qw(warningsToBrowser fatalsToBrowser);
use strict;
print "Content-type: text/html\n\n";
print <<END2;
<html>
<head><title>LOGIN</title></head>
<body>
<table>
<tr>
<td background="C:/Program Files/Apache Software Foundation/Apache2.2/cgi-
bin/template_3/images/login2222.PNG" style="height: 135px; width:
100px;">
<img src="C:/Program Files/Apache Software Foundation/Apache2.2/cgi-
bin/template_3/images/ineer-top-left.gif"/>
</td>
</tr>
</table>
</body>
</html>
END2
Among these two images, the td tag's 'background image' is getting displayed properly, BUT not the image within td.
Actually, i tried changing the content-type to "image/gif", but it did not work. i tried changing the src to "../template_3/images/ineer-top-left.gif" or something like "~/template_3/images/ineer-top-left.gif",but it did not work.
When i right clicked the image in the browser and checked the Properties "it gives the TYPE: not available SIZE : not available BUT the ADDRESS(URL) is Correct. Can anybody Please Help me find the solution.Thank you
Upvotes: 2
Views: 6006
Reputation: 11
Hope this might work
#!C:\perl\bin\perl.exe
use CGI::Carp qw(warningsToBrowser fatalsToBrowser);
use strict;
print "Content-type: text/html\n\n";
print '
<html>
<head><title>LOGIN</title></head>
<body>
<table>
<tr>
<td background="../login2222.PNG" style="height: 135px; width:
100px;">
<img src="../ineer-top-left.gif"/>
</td>
</tr>
</table>
</body>
</html>
';
Upvotes: 1
Reputation: 69284
Firstly, the URLs you give for your images need to be real URLs and not file paths.
And secondly, your web server is probably configured to think that everything in the cgi-bin directory is a CGI program. That means that if you give it a URL which points to that directory, the web server will try to execute the program rather than directly serving the content. You'll want to move static content (like images) out of the cgi-bin directory.
Upvotes: 3
Reputation: 7403
Since you're calling this CGI, you must be running a web server (apache?), so I'm guessing you're accessing it at localhost. In that case, consider using a relative path like "/cgi-bin/template_3/images/ineer-top-left.gif" or an absolute path like "http://127.0.0.1/cgi-bin/template_3/images/ineer-top-left.gif" rather than a location on your filesystem. You may have to play around with where you store the images and where the root directory of your site is.
Upvotes: 4