【发布时间】:2018-07-17 10:31:27
【问题描述】:
我需要在 php 页面中打开 xml 文件。该文件位于我在 PC 上创建的共享文件夹中。可以从连接到服务器的其他 PC 访问文件。我怎样才能做到这一点? 谢谢!
试过这个:
$file_read = file_get_contents('file:///10.8.8.89/test/20180716_BT-0444-0445.xml');
$file_read = preg_replace('/&/', ' and ', $file_read);
echo $file_read;
但代码的行为就像文件不存在一样。 在此之前,我从 ftp 服务器获取 xml 文件,它运行良好。
【问题讨论】:
-
尝试删除
file:///,如果 apache 或 nginx 没有提供 IP,请尝试删除该 IP -
@delboy1978uk 不起作用 :(
-
它应该是
file:///actual/path/to/file或http://10.8.8.89/etc/etc。首先在浏览器中尝试两者 -
@delboy1978uk
file://10.8.8.89/test工作正常并打开目录,但http://10.8.8.89/test根本打不开 -
这很奇怪。您没有以该 ip 作为名称的文件夹吗? :-P
标签: php xml file-get-contents smb file-sharing