• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 263
  • Last Modified:

cgi

i have a directory structure:

/v/blah.com/ast/

ls -l gives 3 directory
images
data
www

if we go to www and ls -l  i have

/www/oos/oos.cgi

in my cgi script
use CONFIG;

print"                <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" bgcolor=\"#3399CC\" width=\"100%\" height=\"60\">
<tr>
<td colspan=\"2\"    BACKGROUND = $CONFIG::IMAGE/1pixelwidth.gif id=\"fillbgtop\"><IMG height=25 src=http://www.xyz.com/images/clear.gif border=0></td>
</tr>
                </table>
";

it is not abe to read imgae $CONFIG::IMAGE/1pixelwidth.gif

CONFIG.pm contains
our $IMAGE = "/v/blah.com/ast/images

why??
0
shahrahulb
Asked:
shahrahulb
  • 5
  • 3
  • 3
  • +1
2 Solutions
 
shahrahulbAuthor Commented:
if the image is present in  /v/blah.com/ast/www/oos

and if i use  BACKGROUND = $CONFIG::IMAGE/1pixelwidth.gif

then it works fine

but i wantto store all my images in sepertae directory
0
 
ahoffmannCommented:
what is DocuemtRoot of your server?
0
 
TintinCommented:
You are confusing directory paths with URL paths.

/v/blah.com/ast/images is the path on the server.  In almost all cases, this is not the same path that is used to access an image in that directory via the webserver.

At a guess, you should set

$IMAGE = 'images';

Assuming of course, that the images directory is within your Document Root or has be set up with an alias.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
shahrahulbAuthor Commented:
only the image is not working

if i use

 my $c = File::CounterFile->new("$CONFIG::DATA/$file"); in my cgi script
this works fine

CONFIG.pm contains: our DATA = "/v/blah.com/ast/data"
0
 
TintinCommented:
Did you update the setting for $CONFIG::IMAGE as suggested?

What URL do you use the view the image in your browser?  Once you know that, you have the image path you need to use.  I think you will probably just need to set it to '/images'
0
 
shahrahulbAuthor Commented:

url is  http://blah.com/oosui/oos-ui.cgi

location of oos-ui.cgi  =   /v/blah.com/ast/www/oosui/oos-ui.cgi
location of images     =   /v/blah.com/ast/images
0
 
shahrahulbAuthor Commented:
DocumentRoot /v/blah.com/ast/www
0
 
ahoffmannCommented:
mv /v/blah.com/ast/images /v/blah.com/ast/www/oosui/images

then in CONFIG.pm:
our $IMAGE = "/v/blah.com/ast/www/oosui/images"
0
 
shahrahulbAuthor Commented:
i know this already  but i want to seperate my image file from oosui directory
0
 
TintinCommented:
Unless you change your webserver configuration, you will need to move your images under your document root, otherwise they will not be viewable.
0
 
ahoffmannCommented:
in httpd.conf set:

Alias /images/ "/v/blah.com/ast/images/"
0
 
perlpengoCommented:
You have to understand two things.
Perls' understands the path to your image dir  as "/v/blah.com/ast/images"
But the web server don't see that unless you tell him so .

Let say you have in your httpd.conf
ServerRoot "/v/blah.com/ast"

Now when you tell him to search for the image file (1pixelwidth.gif) in $CONFIG::IMAGE,
if you have
$IMAGE = "/v/blah.com/ast/images";
he will try to search for a file which will be in the actual dir "/v/blah.com/ast/v/blah.com/ast/images". But you don't have any path like this on your hard drive.
On the other hand, perl Will get that path for you ($IMAGE = "/v/blah.com/ast/images";)  cause it is on your hard drive.

So to make the web server get you that image you have to give him the path starting after the
ServerRoot "/v/blah.com/ast"
which in your case is just "/images". So you also have to add to your httpd.conf
Alias /images "/v/blah.com/ast/images"

to achive this you also have to change your CONFIG.pm to this
our $IMAGE_PATH = "/v/blah.com/ast/images";
our $IMAGE = $IMAGE_PATH;
$IMAGE =~ s/.*\//\//;

or
just
our $IMAGE = "/images";               (but i thought that you had your reasons to put the actual path)

so now your line
<td colspan=\"2\"    BACKGROUND = $CONFIG::IMAGE/1pixelwidth.gif id=\"fillbgtop\">
turns to <td colspan=\"2\"    BACKGROUND = /images/1pixelwidth.gif id=\"fillbgtop\">  
which your server understands
and not to
<td colspan=\"2\"    BACKGROUND = /v/blah.com/ast/images/1pixelwidth.gif id=\"fillbgtop\">
which he doesn't

Of course if you have
ServerRoot "/v/blah.com" then you also need
Alias /images "/v/blah.com/ast/images".
Ecxept if you have
Alias /ast "/v/blah.com/ast"
so you have to tell him that it is in your "/ast/images" by setting $IMAGE="/ast/images";
then your line becomes like this
 <td colspan=\"2\"    BACKGROUND = /ast/images/1pixelwidth.gif id=\"fillbgtop\">  

all of these would be much more clear if you have said from the start what kind of ServerRoot you have, what kind of DocumentRoot and what kind of Alias.
I hope i gave you a clue.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 5
  • 3
  • 3
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now