映射网络驱动器

发布于 2024-08-28 04:10:53 字数 505 浏览 4 评论 0原文

我已将网络驱动器映射到家庭网络中的计算机。现在我尝试通过 PHP 访问它 - 我做了这个快速测试:

echo opendir('Z:\\');

这给了我:

Warning: opendir(Z:\) [function.opendir]: failed to open dir: No error in C:\wamp\www\webs\tester-function.php  on line 3

我在这里做错了什么?

我不希望我的用户输入 UNC 路径,所以有没有办法为他们获取 UNC 路径,也许当我尝试访问它时这会起作用?这在 Microsoft 语言中是可能的,但我不确定如何让 PHP 做到这一点 - 也许使用 cmd.exe 命令?

请注意,映射的驱动器确实存在,正如我所看到的那样,并且我可以访问它。它似乎也不是权限问题,因为我假设它会抱怨如果它可以访问该驱动器......对吗?

感谢大家的帮助

I have mapped a network drive to a computer in my home network. Now I am trying to access it via PHP - I did this quick test:

echo opendir('Z:\\');

This gives me:

Warning: opendir(Z:\) [function.opendir]: failed to open dir: No error in C:\wamp\www\webs\tester-function.php  on line 3

What have I done wrong here?

I don't want my users typing in the UNC path so is there a way to get the UNC path for them and maybe that will work when I try to access it? This is possible in Microsoft languages but I am not sure how to get PHP to do this - maybe using a cmd.exe command?

Please note, the mapped drive does exist as I can see it and I can access it. It also does not appear to be a permissions problem as I am assuming it would of complained about this IF it could access that drive...right?

Thanks all for any help

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

街角迷惘 2024-09-04 04:10:53

用户对 opendir() 贡献的注释有:

我试图使用此 opendir 函数访问网络驱动器。我读了很多帖子说访问网络驱动器几乎是不可能的,最后我找到了答案;要在同一台计算机或另一台计算机上使用 PHP 访问网络驱动器,需要执行 2 个步骤。

在这种情况下,用户权限似乎确实是问题所在,这可能与您的权限不同,具体取决于运行 PHP/Web 服务器的用户。

The User Contributed Notes to opendir() have this:

I was trying to access network drives using this opendir function. I read so many posts saying that it was almost impossible to access a network drive and finally, I found the answer; there are 2 steps to be followed to access a network drive with PHP either on the same machine or another machine.

in this case, the user rights seemed indeed to be the problem, which can be different from your rights depending on what user PHP / the web server are running on.

我一向站在原地 2024-09-04 04:10:53

通过转到“开始”->“打开服务 MMC”运行(如果使用 Windows 7,则使用搜索框)并键入 Services.msc 并按 Enter 键。
找到 Apache 服务。由于从未使用过 WAMP,我不知道它的名字是什么。希望它以“Apache”这个词开头,因此应该不会太难找到。
右键单击该服务并选择属性。
切换到登录选项卡。
选择“此帐户:”旁边的单选按钮,然后输入要在其下运行 Apache 的用户帐户的凭据。如果是网络/域帐户,请使用“DOMAIN\user”语法(或使用“浏览”按钮搜索帐户)。
选择“确定”并重新启动 Apache 服务。
通过在任务管理器中查找“httpd.exe”进程并检查该进程正在哪个用户名下运行,验证您的更改是否有效。

参考http://board.phpbuilder.com/board/showthread。 php?t=10371870&page=2

Open the Services MMC by going to Start -> Run (or by using the search box, if using Windows 7) and typing Services.msc and pressing enter.
Find the Apache service. Having never used WAMP, I have no idea what it's been named. Hopefully it starts with the word "Apache" though, and thus shouldn't be too hard to find.
Right-click on the service and select Properties.
Switch to the Log On tab.
Select the radio button next to "This account:" and enter in the credentials for the user account you want to run Apache under. If it's a network/domain account, use the "DOMAIN\user" syntax (or search for the account using the Browse button).
Select OK and restart the Apache service.
Verify that your changes worked by looking for the "httpd.exe" process in Task Manager and checking to see which user name the process is running under.

reference http://board.phpbuilder.com/board/showthread.php?t=10371870&page=2

野却迷人 2024-09-04 04:10:53

简单,使用:“\\\\server\\dir\\subfolder”作为路径。确保您可以访问“服务器”。

对我有用。
<代码>
$arquivo = "\\\\服务器\\目录\\子文件夹\\文件.txt";
回声 is_file($arquivo); //打印1。

simple, use: "\\\\server\\dir\\subfolder" as the path. make sure you can access the "server".

works for me.

$arquivo = "\\\\server\\dir\\subfolder\\file.txt";
echo is_file($arquivo); //print 1.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文