View Single Post

  #1 (permalink)  
Old 07-04-2003
Steve Brecher
 
Posts: n/a
Default Why does this relative file path work?

On a shared Linux/Apache host, my directory structure is as follows:

home
data
HTML
cgi
topic
downloads

topic contains page.html (and also the "downloads" directory). page.html
contains a link to cgi/script.pl. script.pl increments a count in a data
file and then redirects the client to download a file:

$k_counts_filepath = "../../data/hes_dl_counts.txt";
$k_target_dir_uri = "../../topic/downloads/";
# code to validate existence of download target and to increment counter
goes here
if ($ok) {
print "Location: $k_target_dir_uri$targetname\n";
print "Status: 302 Found\n\n"; }
else {
print "Status: 404 Not found\n\n"; }

The double-up (../..) in the path to the file in the "data" directory seems
straightforward; it's relative to the cgi directory which contains the
script.

But notice the ../.. in the path to the "downloads" directory. Wanting to
use a relative rather than absolute path I arrived at this by trial and
error, but I don't understand why it works. What is the base directory that
the "../.." is being applied to?

--
For mail, please use my surname where indicated:
steve@surname.reno.nv.us (Steve Brecher)