在安装在 Windows XP 计算机上的 PHP (XAMPP) 中,我正在尝试读取本地网络服务器上存在的目录。我正在使用 is_dir()
来检查它是否是我可以读取的目录。
在 Windows 资源管理器中,我键入 \\\server\dir
并显示该目录。
当我映射网络驱动器时,a 也可以使用 z:\dir
访问它。
在 PHP 中我有那个脚本:
<?php if( is_dir($dir){ echo 'success' } ) ?>
对于 $dir
我试过:
/server/dir
//server/dir
\server\dir
\\server\dir
\\\\server\\dir
和
z:\dir
z:\\dir
z:/目录
z://目录
但是我从来没有成功过? 任何想法? 谢谢
最佳答案
我通过更改服务器注册表中的一些内容解决了这个问题,如本次讨论的最后一个答案中所述:
http://bugs.php.net/bug.php?id=25805
无论如何都要感谢 VolkerK 和 Gumbo! 我喜欢 stackoverflow 和他们的好人,他们帮助你的速度非常快!!
编辑(取自 php.net):
The service has limited access to network resources, such as shares and pipes, because it has no credentials and must connect using a null session. The following registry key contains the NullSessionPipes and NullSessionShares values, which are used to specify the pipes and shares to which null sessions may connect: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters Alternatively, you could add the REG_DWORD value RestrictNullSessAccess to the key and set it to 0 to allow all null sessions to access all pipes and shares created on that machine.`
将 RestrictNullSessAccess=0 添加到您的注册表。
关于windows下php访问网络路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1153824/