小编hun*_*ran的帖子

使用 ip 或计算机名在网络上使用 php 读取文件

当我通过 ip 或计算机名在 LAN 网络上使用 php 读取文件时。

$url = "\\\\192.168.0.200\\testshare\\1.txt";
        if(file_exists($url) == TRUE) {
            echo "OK";
        } else {
            echo "Error";
        }
Run Code Online (Sandbox Code Playgroud)

结果:总是“错误”。如果我使用函数 file_get_contents ($url , true); 结果:

Warning: file_get_contents(\\192.168.0.200\testshare\1.txt) [function.file-get-contents]: failed to open stream: Permission denied in D:\services\htdocs\test.php on line 3
Run Code Online (Sandbox Code Playgroud)

当然,文件夹“testshare”设置共享和权限每个人都完全控制。如果我用磁带浏览器:\192.168.0.200\testshare\1.txt 它读取文件 1.txt 的内容。你能帮助我吗?每个想法都帮助我,我非常感谢。

php file-get-contents file-exists

5
推荐指数
1
解决办法
1万
查看次数

标签 统计

file-exists ×1

file-get-contents ×1

php ×1