Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I m new to perl and cgi and I have been trying to add an image to my web page but the image doesnt appear.I have tried to change the file permission too and that didnt work either. Following is what i'm using. $cgi->img(-src=>'http://localhost/cgi-bin/pics/PD4.jpg',-width=> '82', -height=> '82');

Replies are listed 'Best First'.
Re: image not shown in my web page
by Anonymous Monk on May 05, 2011 at 11:14 UTC
    1) always check the link manually 2) always check the http response code 3) always check your server logs 4) in common configs apache won't serve images from cgi-bin
      Thanks for the response point 1) checked manually with file:///C:/Server/Apache2/cgi-bin/pics/PD4.jpg.IT works. 2) not sure about this 3) no error on the log.Its just that everything works except the image. 4) is there any work around if apache wont server images ? Please help.

        Why do you manually check

        file:///C:/Server/Apache2/cgi-bin/pics/PD4.jpg

        if you use

        http://localhost/cgi-bin/pics/PD4.jpg

        in your code?

        What error do you get in the logs for the image?

        Also, read the Apache documentation on how to configure Apache. This has nothing to do with Perl. You will need to configure Apache so that it serves images from a directory. This directory should not be cgi-bin.

        checked manually with file:///C:/Server/Apache2/cgi-bin/pics/PD4.jpg.IT works.

        file: is not http: If you're trying to debug a problem with http://localhost.... you don't reach for file:

        not sure about this

        Yeah, the file: bit gave it away, which is why you should take the time now to learn about the internet.

        This is one way you might check

        $ lwp-request -USEd http://127.0.0.1:5000/ GET http://127.0.0.1:5000/ User-Agent: lwp-request/6.00 libwww-perl/6.02 200 OK Date: Thu, 05 May 2011 11:36:49 GMT Date: Thu, 05 May 2011 11:36:49 GMT Server: HTTP::Server::PSGI Content-Length: 6064 Client-Date: Thu, 05 May 2011 11:36:49 GMT Client-Peer: 127.0.0.1:5000 Client-Response-Num: 1

        no error on the log.Its just that everything works except the image.

        unlikely

        is there any work around if apache wont server images ?

        Either don't keep images in cgi-bin, or configure apache to serve images from cgi-bin (I'm assuming its possible).