within PHP (XAMPP) installed on a Windows XP Computer Im trying to read a dir which exists on a local network server. Im using is_dir()
to check whether it is a dir that I can read.
In Windows Explorer I type \\\server\dir
and that dir is being shown.
When I map a network drive a can access it with z:\dir
as well.
In PHP I have that script:
<?php if( is_dir($dir){ echo 'success' } ) ?>
For $dir
I tried:
/server/dir
//server/dir
\server\dir
\\server\dir
\\\\server\\dir
and
z:\dir
z:\\dir
z:/dir
z://dir
But I never get success? Any idea? thx
I solved it by changing some stuff in the registry of the server as explained in the last answer of this discussion:
http://bugs.php.net/bug.php?id=25805
Thanks to VolkerK and Gumbo anyway! I love stackoverflow and their great people who help you so incredibly fast!!
EDIT (taken from php.net):
add RestrictNullSessAccess=0 to your registery.
Try the
file:
URI scheme:The begin is always
file://
. The next path segment is the server. If it’s on your local machine, leave it blank (see second example). See also File URIs in Windows.You probably let xampp install apache as service and run the php scripts trough this apache. And the apache service (running as localsystem) is not allowed to access the network the way your user account is.
You can test this by starting the apache as console application (apache_start.bat in the xampp directory should do that) and run the script again. You can use both forward and backward slashes in the unc path. I'd suggest using //server/share since php doesn't care about / in string literals.