我有一个闪存驱动器(或硬盘)连接到 Linksys 路由器,并将其设置为无需登录即可访问。然后我在计算机(Windows 7 Proffesional x64)上设置网络驱动器。我尝试了 opendir(\192.168.1.1);但我收到此错误
Warning: opendir(\\192.168.1.1\s2,\\192.168.1.1\s2): The network name cannot be found. (code: 67) in C:\xampp\htdocs\movies.php on line 4
Warning: opendir(\\192.168.1.1\s2): failed to open dir: No such file or directory in C:\xampp\htdocs\movies.php on line 4
Warning: readdir() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\movies.php on line 5
然后我在 php.net opendir 评论中尝试了一些技巧,但是当我尝试以我的帐户登录 apache 时,我遇到了错误:
Windows could not start the apache2.4 service on Local Computer Error 1069: The service did not start due to a logon failure.
PHP 代码:
$path = '\\192.168.1.1\\s2';
$dir = opendir($path);
while($temp = readdir($dir))echo $temp;
编辑:好吧,我让 apache 登录了我专门为此目的创建的管理员帐户,但我仍然收到此错误:
Warning: opendir(\\192.168.1.1\s2\,\\192.168.1.1\s2\): The network name cannot be found. (code: 67) in C:\xampp\htdocs\movies.php on line 4
最佳答案
\192.168.1.1
是网络共享的无效地址。您尝试过 \\192.168.1.1
吗?
在这两种情况下,您都应该转义 \
并将地址写为带引号的正确字符串。
此外,\\192.168.1.1
本身并不是“有效文件夹”,您必须指定此 IP 地址下的网络共享之一。
话虽如此,您应该使用opendir("\\\\192.168.1.1\\share")
。
关于apache - 使用 php open dir 访问网络驱动器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17002507/