开发者社区 问答 正文

php如何读取局域网文件???:报错

我能访问一个文件,如:

\\192.168.0.17\Default\Bookmarks

如何用php读取过来呢?我试着

echo file_get_contents('//192.168.0.17/Default/Bookmarks')

但是不行啊,是不是我的路径写的有问题?

不能在远程架设http或ftp。

谢谢~~

展开
收起
kun坤 2020-06-07 13:38:14 680 分享 版权
1 条回答
写回答
取消 提交回答
  • 帮帮我哈~######你那么做肯定不行的。貌似需要LDAP扩展######呵,咋用呢######

    php没权限,读不了web目录外的。你可以写别的能在本地运行的脚本或程序来执行读取程序的任务,这个程序或脚本再和你的php交互。

    ######

    try it

    <?php


    // Define the parameters for the shell command
    $location  "\\servername\sharename" ;
    $user  "USERNAME" ;
    $pass  "PASSWORD" ;
    $letter  "Z" ;

    // Map the drive
    system ( "net use " . $letter . ": \"" . $location . "\" " . $pass . " /user:" . $user . " /persistent:no>nul 2>&1" );

    // Open the directory
    $dir  opendir ( $letter . ":/an/example/path" )

    ...

    ?>######几个哥误人子弟,直接用网络影射成本地盘,然后试试用file或fopen
    2020-06-07 13:38:19
    赞同 展开评论