Forum Moderators: coopster

Message Too Old, No Replies

accessing network files via a script

         

supermanjnk

1:03 pm on Aug 10, 2005 (gmt 0)

10+ Year Member



I'm running IIS 5 and php5.
I have tried the following

if (opendir('\\\\server\\folder\\TEST')){
echo "dir";
} else {
echo "no dir";
}

it always echo's "no dir" I've tried various different ways to do the unc path such as:

//server/folder/TEST
\\\server\folder\TEST
i've even tried mapping the drive on the server
I:\\TEST

and others. I know it's not a permissions issue, I have the folders set to everyone having full control.

coopster

2:06 am on Aug 12, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



I'm not sure. One trick is to use the PHP constant DIRECTORY_SEPARATOR to build paths.

// If using WINDOWS, you can use str_replace to change the directory separator: 
$dir = $_SERVER['DOCUMENT_ROOT'] . '/subdir1/subdir2';
if (stristr(PHP_OS, 'WIN')) {
$dir = str_replace('/', DIRECTORY_SEPARATOR, $dir);
}