Php读取网络共享文件的文件内容

sad*_*ave 6 php file network-share

我正在寻找一种方法来读取位于网络共享上的文件的文件内容.我可以使用共享主机的IP地址和共享文件夹到达该位置,但我不知道执行该file_get_contents的正确命令和语法?FOPEN?

$text = fopen('//128.251.xxx.xxx/Common/sample.txt', 'r');
Run Code Online (Sandbox Code Playgroud)

或类似的东西?

更新*我也无法通过浏览器窗口访问该文件,虽然我知道该文件位于该确切的目录中...

irc*_*ell 8

最好的方法(根据您的需要)只需将其安装在本地机器上,然后从安装座中读取.这样就可以抽象出所有的网络交互.

所以,在Linux中:

mount -t cifs //192.168.XXX.XXX/share /path/to/mount -o user=username,password=password
Run Code Online (Sandbox Code Playgroud)

然后,在php中,只需从挂载点访问它:

$data = file_get_contents('/path/to/mount/path/to/file.txt');
Run Code Online (Sandbox Code Playgroud)