Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

cgi/img prob

Status
Not open for further replies.

tommycahir1

Programmer
Feb 20, 2004
34
0
0
IE
hi all
i new to cgi and html and i am just trying to write a cgi script that shows an image to the screen.. the image is located in the same folder as the script but it aint appearing on screen .. the alt text is though..
shown below is the code that i have so far. this code is part of a much larger cgi script which will call this function to output the image mulitple times
print header;
print qq(<html>);
print qq(<head>);
print qq(<title>Results</title>);
print qq(</head>);
print qq(<body bgcolor = lemonchiffon>);
print qq(<CENTER><H1>Results</h1><CENTER><br><br>);
print qq(<h3><img src = "/A.jpg" alt = "should be pic ere"></h3>);
print qq(</body>);
print qq(</html>);
any help would be greatly appreciated..
tanx
tommy
 
check the path to your image.

"/A.jpg" doesn't look right. It should be

"A.jpg" or
"../A.jpg" or
"dir/A.jpg"

you get the idea.
 
tried the
A.jpg -- didnt work
./A.jpg -- didnt work
/cgi-bin/A.jpg -- didnt work either any more ideas
 
If the image is in the same folder as the script that is showing in the url of the web browser, then "A.jpg" should have worked. If not, then you probably have a problem with the permissions on your image.

 
Is the image truly named A.jpg or is it a.jpg? Unix machines are case sensitive and consider these as different file names. Also, more often then not, images are in a seperate directly than the html pages - usually in a directory named "images". If this is your case, then you'd want to do this: print qq(<h3><img src = "images/A.jpg" alt = "should be pic ere"></h3>);

There's always a better way. The fun is trying to find it!
 
the permissions are ok as they set so that everybody can read them..
the pic is truly named A.jpg not anything else
tried the images option with
print qq(<h3><img src = "/images/A.jpg" alt = "should be pic ere"></h3>);

i completly lost at this stage as to how to display the images
 
So have you been able to type in the url to the image in a browser and get it to display?

 
Assuming you're using the correct url, the only other thing I can think of is that your web server is not configured to serve up images from the cgi-bin directory. What web server are you running?

You can also check your server's error log and see if it gives you any useful info.

 
Can you post a link to your site?

There's always a better way. The fun is trying to find it!
 
Assuming Apache (which does give errors when trying to serve images from cgi-bin)

move the images to the webroot
vhtdocs/mysite/images

and refer to it in the script as "../../images/A.jpg"

HTH
--Paul
 
yipee prob solved tanx for all the help lads it greatly appreciated

thanking you
tommy :)
 
Tommy...

If you don't tell us how you fixed it, we'll never sleep tonite!

There's always a better way. The fun is trying to find it!
 
My Thanks to PaulTag,
I was trying to do the same thing with an RPGILE CGI program, Pauls solution solved my problem as well.

I just added a folder called "images' into htdocs and entered "../images/xxx.jpg"

Thanks again
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top