Page 1 of 1

List directory on another server

Posted: Fri Feb 10, 2006 11:05 am
by SandyD
Hi all, hoping someone will take pity on me with some PHP code

I have some code (pinched from some google search) that has been added to a user-defined tag and is supposed to give me a list of files in the specified directory.

However, on running it, it only produces the "pre..." and "post" code lines.

I want to use it so that any new procedures added to the directory will be displayed automatically.

Any ideas?

Code: Select all

echo("<h3>--- Pre dir code ---</h3>");

$dir = "\\server\share\procedures";
$dh  = opendir(dirname($dir));
while (false !== ($filename = readdir($dh))) {
   echo($filename . " ");
}

echo("<h3>--- Post dir code ---</h3>");
P.S. The directory is on another server.

Re: List directory on another server

Posted: Fri Feb 10, 2006 11:13 am
by cyberman
SandyD wrote: P.S. The directory is on another server.
Your script needs the full path for the directory ...

Re: List directory on another server

Posted: Fri Feb 10, 2006 11:15 am
by SandyD
Hi cyberman,

can you explain what you mean by "full path"?

And/or possibly show me in code.

Re: List directory on another server

Posted: Fri Feb 10, 2006 11:31 am
by cyberman
SandyD wrote:

Code: Select all

$dir = "\\server\share\procedures";
With this line $dir is set to your server. Cause you wanna read the directory from another server the url must located in this line. But the script must also have the permission to read the external directory ...

Re: List directory on another server

Posted: Fri Feb 10, 2006 12:25 pm
by SandyD
Thanks for the info, managed to get it to work