Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re^2: Image doesnot display in perl cgi when moved code from linux to windows

by saurabh220837 (Initiate)
on Jul 23, 2015 at 09:01 UTC ( [id://1135973]=note: print w/replies, xml ) Need Help??


in reply to Re: Image doesnot display in perl cgi when moved code from linux to windows
in thread Image doesnot display in perl cgi when moved code from linux to windows

URL I am accesing is http://localhost/cgi-bin/index.cgi

the code for this page is

#!perl use DBI; use CGI::Carp "fatalsToBrowser"; use CGI; my $q = CGI->new(); print $q->header; print $q->img ({ -src => "C:/Apache24/images/tree.jpeg", -align=>"CENT +ER" }); print $q->start_html; print $q->start_form( -method=>"get" , -action => "form_1.cgi" , ); print $q->div( {-align=> 'center' , }, $q->br,$q->br,$q->submit ( - +value=> 'Add New Employee' , -name => 'action' ,) ); print $q->end_form; print $q->start_form( -method=>"post" , -action => "db_connect.cgi" , +); print $q->div( {-align=> 'center' , }, $q->br,$q->br,$q->submit ( - +value=> 'View All Employees' , -name => 'action' ,) ); print $q->end_form; print $q->start_form( -method=>"get" , -action => "db_insert.cgi" , ); print $q->div( {-align=> 'center' , }, $q->br,$q->br,$q->submit ( - +value=> 'Delete Employee' , -name => 'action' ,) ); print $q->end_form; print $q->end_html;

Even if i give full image path , as given in above source code, it doesnt show up. while I can access same via command prompt

  • Comment on Re^2: Image doesnot display in perl cgi when moved code from linux to windows
  • Download Code

Replies are listed 'Best First'.
Re^3: Image doesnot display in perl cgi when moved code from linux to windows
by roboticus (Chancellor) on Jul 23, 2015 at 10:46 UTC

    saurabh220837:

    You're using "C:/Apache24/images/tree.jpeg" as the image source. I can guarantee you that that's not the URL that will access the file.

    As people have mentioned to you, you'll need to check the apache configuration to find out how to tell it where the image is.

    For example, if I set up a web server, I might configure it like this:

    Alias /images C:/Apache24/images/ DocumentRoot D:/CoolWebsiteProject/html Alias /cgi-bin D:/CoolWebsiteProject/bin

    So as far as the outside world is concerned "https://YourWebsite.com/images/tree.jpeg" would be the location that the outside world would use to access your image file. Similarly, "https://YourWebsite.com/cgi-bin/index.cgi" would be coming from D:/CoolwebsiteProject/bin. That's why you need to look at your configuration. Any time you're putting something like "C:/local/path/to/file" in an web page, you're doing it wrong.

    ...roboticus

    When your only tool is a hammer, all problems look like your thumb.

Re^3: Image doesnot display in perl cgi when moved code from linux to windows
by RichardK (Parson) on Jul 23, 2015 at 10:00 UTC

    Have you checked the webserver log for any errors?

    Using an absolute path on the file system doesn't look right, try specifying that path as relative to the DocumentRoot.

Re^3: Image doesnot display in perl cgi when moved code from linux to windows
by MidLifeXis (Monsignor) on Jul 23, 2015 at 12:38 UTC

    In addition to the path location mentioned above, you are also printing the <img> tag outside of the <html> block. The generated HTML is not valid. Access the source of the resource present at your URL (see LWP::UserAgent or curl or even echo 'GET /my/url HTTP/1.0' | telnet hostname 80 and take a look at what is being generated.

    --MidLifeXis

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1135973]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (8)
As of 2024-04-18 08:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found