View Full Version : Image display problem
naveenlinux
03-22-2007, 06:07 AM
I am using CGI.pm module to display an image button.
print $query->image_button(-name=>'Test',
-src=>'/cgi-bin/NYNY.gif',
-align=>'MIDDLE');
But image is not getting displayed in Firefox. In Konqueror though, an icon is displayed which is displayed whenever some image is not found.
I dont understand whats the problem here...
Are there any configurations to be made on Apache web server to allow displaying of images?
KevinADC
03-22-2007, 07:53 AM
probably the image file should not be in the cgi-bin, put it in a folder above the cgi-bin:
-src=>'images/NYNY.gif',
the cgi-bin generally only allows scripts to be accessed
naveenlinux
03-22-2007, 03:33 PM
I have put it just above the cgi-bin directory and also checked that the image file is executable. But its not being displayed.
Is there anything to be enabled in the web browser?
KevinADC
03-22-2007, 08:27 PM
I have put it just above the cgi-bin directory and also checked that the image file is executable. But its not being displayed.
Is there anything to be enabled in the web browser?
Not that I am aware of. Post the new code you are trying to use.
naveenlinux
03-23-2007, 07:51 AM
Here's the code:
print $query->header(-type=>'text/html'),
$query->start_html,
$query->start_form,
$query->image_button(-name=>'Test',
-src=>'images/NYNY.gif',
-align=>'MIDDLE'),
$query->end_form,
$query->end_html;
The images directory is at the same level as cgi-bin directory.
But the image is not displayed. I even tried putting the images directory in htdocs directory, but to no avail.
KevinADC
03-23-2007, 08:09 AM
you might have to do it like this:
-src=>'../images/NYNY.gif',
if all else fails you can always use the fully qualified web address of the image although that is slower:
-src=>'http://www.mysite.com/images/NYNY.gif',
naveenlinux
03-23-2007, 08:26 AM
Cool... That works. Thanks a lot.
One more related question:
I am using the following to display the image separately:
my $image = '../image/image1.jpeg'
print $query->p(
$query->a({-href=>$image},
$query->img({-src=>$image,
-width=>1024,
-height=>768})
)
);
The image appears pretty nicely. But the image is clickable. When I click on the image the same image reloads.
How can I make that image static, I mean only viewable?
I am not sure I understand that code. I got it from internet, but it works fine.
naveenlinux
03-23-2007, 01:08 PM
My directory hierarchy is:
www
cgi-bin
htdocs
My scripts are in cgi-bin directory.
The images directory should be places in htdocs directory. Only then it works. Placing the images directory any where else proves to be inconsequential and the images will not be displayed.
And the path should be "-src=>'../images/xyz.jpg' ", The "../" puts the script's control in htdocs/ directory.
With the directory structure that I have, "../" does not make any sense at all.
But one thing makes sense to me only scripts go into cgi-bin directory and if something else is to be put on the web-browser then that has to go inside htdocs.
:thumbsup:
KevinADC
03-23-2007, 05:31 PM
Cool... That works. Thanks a lot.
One more related question:
I am using the following to display the image separately:
my $image = '../image/image1.jpeg'
print $query->p(
$query->a({-href=>$image},
$query->img({-src=>$image,
-width=>1024,
-height=>768})
)
);
The image appears pretty nicely. But the image is clickable. When I click on the image the same image reloads.
How can I make that image static, I mean only viewable?
I am not sure I understand that code. I got it from internet, but it works fine.
print $query->p(
$query->img({-src=>$image,
-width=>1024,
-height=>768})
)
);
My personal opinion is that using the CGI module to generate basic htmL code is over kill and often over complicated. I only use the CGI module to print form widgets and headers for the most part where it's used to greater advantage.
But to print an image or other simple html code I would just print it:
print qq~<img src="frog.jpg" width="100" height ="100" alt="a frog!" title="a frog!">~;
but if you prefer to use the CGI module for html generation that is up to you.
vBulletin® v3.8.2, Copyright ©2000-2010, Jelsoft Enterprises Ltd.