tags:

views:

51

answers:

2

Hello everyone,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

+3  A: 

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.

Ben Taitelbaum
Thanks For the Reply, I tried giving both the ways i.e Relative aswell as obsolute but still the same problem persisits.
SUSH
if you type the relative or absolute path to the image into your browser, do you see it there? If you don't then it could be an issue with file permissions, an incorrect path, or your server is setup to only serve cgi files from the cgi-bin directory (it's a good idea to put images into /images anyway)
Ben Taitelbaum
yeah, that means it won't serve up images from your cgi-bin directory. move it to a /images directory (with the same parent as the cgi-bin dir) and try to access it there.
Ben Taitelbaum
i tried this method also but still the problem exists,initally in the "htdoc" i have given the directory path to be cgi-bin then how will it take the path to be someother directory of image which i have created..Completly confused regarding this issue.;-(
SUSH
It sounds like you're running apache, so make sure to understand http://httpd.apache.org/docs/2.1/platform/windows.html (particularly about case sensitivity). Also spend some time reading through the documentation and looking at some example configurations. Make sure you have a DocumentRoot directive, as that directory will be where "/" maps to.
Ben Taitelbaum
Also, make sure you can load a minimal index.html before debugging scripts. If you can load index.html, then try putting an image in that directory and viewing it in your browser. If that works, then you're good.
Ben Taitelbaum
Thanks a lot. it works.
SUSH
+2  A: 

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.

davorg
Am i supposed to make any changes in htdoc?
SUSH
You need to move the images out of the cgi-bin directory and into wherever you store the rest of your site's static content.
davorg
ok Thanks a lot for your reply.
SUSH