Forum Moderators: coopster

Message Too Old, No Replies

php opendir on UNC path

can't browse directory on network share, get bad open

         

andylarks

4:10 pm on Apr 1, 2004 (gmt 0)

10+ Year Member



I'm trying to read in a list of directories within a folder on a network share. I've set things up such that:

web-server - has a local user called webaccess, and I've created a virtual directory, "browse" to: servername\path_to\directory - and allowed "browsing" on it.

file-server - has a local user called webaccess, and webaccess has read permission on the folders in question.

can browse that directory at, for eg.
htp://web-server/browse

However, when I try to open that directory using:

$path="browse";
if (is_dir($full_path)) {
$hndl = opendir($full_path);

I get a bad open.

I tried changing: $path="servername\path_to\directory";
... but get the same error.

Anyone got any idea what I'm doing wrong?

Thansk heaps

Andy

jatar_k

11:29 pm on Apr 2, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



I asked our sysadmin here and he said to try

"\\servername\path\to\dir"

rather than

"servername\path\to\dir"

andylarks

3:07 pm on Apr 14, 2004 (gmt 0)

10+ Year Member



Thanks for the reply. I tried that, and it still wont work

<snip>
$full_path="//remote-server/Shared-folder/Projects";
$hndl = opendir($full_path);
$list = array();
while((@$file=readdir($hndl))!== false) {
if($file!= '.' && $file!= '..') {
$list[] = $file;
}
}
@closedir($hndl);
</snip>

gives me:

Warning: opendir(//remote-server/Shared-folder/Projects): failed to open dir: Invalid argument in ...

any other ideas?

andylarks

3:25 pm on Apr 14, 2004 (gmt 0)

10+ Year Member



FIXED IT!

Oh, so happy!

Ok, for anyone else who may get stuck, the problem was with the IIS password management.

Open up IIS manager, and select the folder that contains the php file that is trying to access the UNC path. Right click, select properties. In there, click on the "Directory security" tab, and click on "Edit" for the annonymous. In there, de-select the "allow IIS to manage password", or something like that, and see if that fixes it :)

Thanks