PHP 和 NAS(IIS 7.5、Windows Server 2008)
我如何访问文件夹,例如
\\10.200.0.3\some_folder
user name: user
password: pass
是否可以映射网络设备然后使用 php 访问它? 请帮助我连接到此共享并访问那里的文件..
how can i access folders like
\\10.200.0.3\some_folder
user name: user
password: pass
is it possible to map network device then access it using php?
please help me connect to this share and access files there..
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
尝试其中之一;
Try one of these;
由于您将使用 IIS/Apache 用户运行 PHP,因此请确保服务器用户也有权访问网络共享文件夹。一旦您确定 IIS 用户确实有权访问共享文件夹,您可以尝试使用以下路径列出共享文件夹的内容:
$target_path = '\\\\server\\images\\';
看看这个问题,可能会有所帮助:
PHP:上传文件到网络共享文件夹
Since you will be running PHP using IIS/Apache user make sure server user also has permissions to access network shared folder. Once you are sure IIS user does have permissions to access shared folder, you may try listing contents of shared folder by using path such as:
$target_path = '\\\\server\\images\\';
Have a look at this questions, might be helpful:
PHP: upload files to network shared folder
您正在寻找的是服务器消息块 (SMB) 或开源实现 SAMBA。
要在 PHP 中使用此功能,您可以查看 smbwebclient。
然而,您可以简单地将驱动器映射添加到 Windows 服务器上的共享,为其分配固定字母(如 Z:),甚至简单地访问
\\hostname\folder
(转义反斜杠)并使用PHP 内置目录命令来从该驱动器读取和写入文件。这会变得非常容易。What you're looking for is Server Message Block (SMB) or the open source implementation SAMBA.
To use this in PHP, you could look at smbwebclient.
You might however simply add a drive map to the share on your Windows server, assign it a fixed letter (like Z:) or even simply access
\\hostname\folder
(escape the backslashes) and use the PHP built in directory commands to read and write the files from that drive. It'll be a helluvalot easier.