期望实现:可以通过php的file_get_contents()方法直接访问局域网内共享目录的文件
(windows下可以直接访问不需要配置,但linux下访问不了。目前可以 1.通过挂载磁盘的方法解决 2.通过调用smbclient实现。 但是不想用这个方法,就想知道能不能通过配置Apache实现。网上说可以,配置如下,但是我试了不可以,不知道有什么问题,权限?)
我在 http-vhosts.conf配置了如下
<code> Servername 127.0.0.1
DirectoryIndex index.php
Documentroot /www/htdocs/
Alias /myshare "//10.173.32.4/myshare"
<Directory "//10.173.32.4/myshare">
AllowOverride None
Order allow,deny
Allow from all
</Directory></code>麻烦指点一下,谢谢!
环境 linux + apache2.4 + php5.6
期望实现:可以通过php的file_get_contents()方法直接访问局域网内共享目录的文件
(windows下可以直接访问不需要配置,但linux下访问不了。目前可以 1.通过挂载磁盘的方法解决 2.通过调用smbclient实现。 但是不想用这个方法,就想知道能不能通过配置Apache实现。网上说可以,配置如下,但是我试了不可以,不知道有什么问题,权限?)
我在 http-vhosts.conf配置了如下
<code> Servername 127.0.0.1
DirectoryIndex index.php
Documentroot /www/htdocs/
Alias /myshare "//10.173.32.4/myshare"
<Directory "//10.173.32.4/myshare">
AllowOverride None
Order allow,deny
Allow from all
</Directory></code>麻烦指点一下,谢谢!
你这个是外部访问,不是 PHP 访问的
正解参见 SO
http://stackoverflow.com/questions/5070545/php-read-file-contents-of-network-share-file
<code>mount -t cifs //10.173.32.4/myshare /www/htdocs/myshare </code>
然后
<code>$data = file_get_contents('/www/htdocs/myshare/file.txt');</code>
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号