On Sun, 8 Mar 2009 09:01:18 +0000, stut...@gmail.com (Stuart) wrote:

>2009/3/8 Clancy <clanc...@cybec.com.au>
>> I want to index the files on a website recursively. The program will run in
>> the site root
>> directory, which GETCWD reports as D:/Websites/Website_1.  I can open any
>> file in the root
>> directory simply using its file name; Joe.dat, for example, and I can
>> opendir for any
>> subdirectory; eg
>>        opendir(Subdirectory_1);
>> but opendir () does not seem to work, and the only way I can find to open
>> the root
>> directory is to give its full path; eg
>>        opendir (D:/Websites/Website_1);
>> I have got the program working by using the full path to open the root
>> directory, and then
>> using relative paths to open the subdirectories and individual files, but
>> this seems
>> rather a kludge, and I am wondering if there is a way to open the root
>> directory without
>> specifying an absolute path?
>The current working directory cannot be trusted to be "right". The best
>option is to use dirname(__FILE__) and add '/..' as many times as needed to
>get from the current file to the document root you're after.

It has always worked for me.  But then I never change directory. But both give 
a hardware
dependent answer; 

echo '<p>Current directory is '.__FILE__.', CWD is '.getcwd().'</p>'; gives

Current directory is D:\Websites\Corybas\Cydaldev\Dev\Testbed_2.php, CWD is

Opendir (Dev); works, opendir (); ought logically to work, but doesn't. (It 
complains it
needs at least one parameter.)

Eventually I found that 

        opendir('../Cydaldev'); does not work
        chdir(Cydaldev); opendir ('..'); does work, but I can't say I like this.

PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to