"Andy Hassall" <an**@andyh.co.uk> wrote in message
news:9t********************************@4ax.com...
On Fri, 23 Jul 2004 14:13:41 -0400, "Nicholas Geraldi"
<ni*********@taconic.net> wrote:
"eXeonical" <sp******@mbnet.fi> wrote in message
news:cd**********@plaza.suomi.net... Nicholas Geraldi wrote:
> I have a script that uses the chdir() function. I know the script
works( > works perfectly on my host ), but when I put the script on my serverhere at > work I get the following error.
>
> Warning: chdir(): No such file or directory (errno 2)
>
> The same script works at my personal host, thats the part that
bothersme. > The host here at work is running PHP 4.3.8. Any suggestions about how
toget > this to work? or maybe another function that does the same thing as
chdir().
Maybe the directory youre trying to chdir() exists on your personal
computer, but does not exists on your server. Thats basically what that
error message says, anyways.
Im using readdir() to get a list of directories(and is_dir() to test to
besure) to change to, it should be able to work in any file system that
supports chdir(). Both Home and work are using Linux ( Red Hat at home
andFidora(sp?) at Work ). But for some reason its not working at Work.
Post some code; a minimal example that demonstrates the problem,
preferably with a couple of examples from 'ls -l' to show what it's supposed to be
reading.
--
Andy Hassall <an**@andyh.co.uk> / Space: disk usage analysis tool
http://www.andyh.co.uk / http://www.andyhsoftware.co.uk/space
The code i am using is this...
<?PHP
function get_protect_dir(){
return array("pictures");
}
function get_dir($dir){
$testing = chdir($dir);
$protected_dir = get_protect_dir();
$directory = '';
$j = 0;
$dh = opendir('.');
while ($filename = readdir($dh)){
$dontcount = 0;
if((!is_file($filename)) && ($filename != '.') && ($filename != '..') &&
(is_dir($filename))){
foreach($protected_dir as $temp_dir){
if($filename == $temp_dir){
$dontcount = 1;
}
}
if($dontcount != 1){
$directory[$j] = $filename;
$j++;
}
}
}
closedir($dh);
return $directory;
}
function rec_dir($dir){
$dir_array = get_dir($dir);
$recurve_dir = '';
echo "<CENTER><TABLE SPAN=\"90%\" CELLSPACING=1 CELLPADDING=10>";
$counter = 1;
foreach($dir_array as $temp_dir){
if(($counter%2) != 0){
echo "<TR>";
}
echo "<TD><TABLE CELLSPACING=0 CELLPADDING=0><TR>";
echo "<TD><FONT SIZE=4><U>$temp_dir</U></FONT></TD></TR>";
$recurve_dir = get_dir($temp_dir);
echo "<TR><TD><FONT SIZE=2>";
if($recurve_dir != 0){
foreach($recurve_dir as $temp2_dir){
echo "<U>$temp2_dir</U>,";
}
}
echo "</FONT></TD></TR>";
echo "</TABLE></TD>";
if(($counter%2) == 0){
echo "</TR>";
}
$counter++;
}
echo "</TR></TD></TABLE></CENTER>";
}
echo "<HTML>";
echo "<BODY>";
rec_dir('.');
echo "</BODY>";
echo "</HTML>";
?>
the directory structure is very simple.
/test
/test/dir_function.php [name of that file]
/test/test2
/test/test2/test21
/test/test2/test22
At home it gives me test just like its supposed too. at work it reads the
top level (test2 in this case) but then gives errors when it tries to
chdir() into test2 to get test21 and test22.
( you should be able to copy and paste that code exactly )
Thanks for the help,
Nick
-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----