奇怪的 php opendir/glob 问题
我对 opendir 有一个奇怪的问题(与 glob 相同的问题):
$dir = "Y:\\\\foldername\\";
if (is_dir($dir)) {
if ($dh = opendir($dir)) {
while (($file = readdir($dh)) !== false) {
echo "filename: $file\n";
}
closedir($dh);
}
}
Y:\ 是一个带有身份验证的网络文件夹。 我的网络服务器名称是 testweb,该脚本名为 tree.php。 不幸的是我的环境是基于Windows的(php 5.2.5 ISAPI,windows 2003服务器)。
当我从运行 IIS 的同一台计算机(http://testweb/tree.php )打开脚本时,一切正常,但如果我从另一台计算机(例如我的笔记本电脑)连接到同一地址,则会出现以下错误:
警告:opendir()..无法打开目录。 D:\web\tree.php 中没有错误
这似乎是一个权限问题,但为什么它是从“本地计算机”而不是从外部工作?我该如何解决这个问题?
感谢您的帮助!!
I have a strange issue with opendir (same problem with glob):
$dir = "Y:\\\\foldername\\";
if (is_dir($dir)) {
if ($dh = opendir($dir)) {
while (($file = readdir($dh)) !== false) {
echo "filename: $file\n";
}
closedir($dh);
}
}
Y:\ is a network folder with authentication.
My webserver name is testweb and this script is called tree.php.
Unfortunately my environment is windows based (php 5.2.5 ISAPI, windows 2003 server).
When I open the script from the same machine where IIS is running (http://testweb/tree.php ) everything works fine but if I connect to the same address from another machine (eg my laptop) I get the following error:
Warning: opendir().. failed to open dir. No error IN D:\web\tree.php
It seems a permissions issue but why it is working from the "local machine" and not from outside? How can I fix this?
Thanks for your help!!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
检查您对该目录的权限..您可以使用名为 is_read 的函数来完成此操作
check your permissions on that directory.. you can do it using the function called is_readable
即使我更改了权限并以管理员身份登录,我也遇到过此错误,但错误仍然存在。
我通过给出函数 opendir() 的绝对路径解决了这个问题,而不是写“子文件夹”,我写了“C:\wamp\www\myproject\subfolder”,这解决了我的问题!
谢谢
I had this error before even when I changed the permission and I logged in as admin the error persisted.
I solved this by giving the absolute path for the function opendir() that is instead of writing "subfolder" I wrote "C:\wamp\www\myproject\subfolder" and this solved my problem !
Thanks