douoyou3348 2012-11-04 17:35
浏览 190
已采纳

file_exists不适用于文件服务器中存在的文件

I am facing a issue such that i am able to link to a file that is present in an http server or a ftp server.. but i am not able to link to a file that is present in a file server..

ie, More Clearly.. if the URL is http://serverpath.com/images/image.jpg or ftp://serverpath.com/images/image.jpg or a remote path the file_exists function gives a true value but if a give a file server path like the similar path as //serverpath/public/images/image.jpg the file_exists function is giving a false value.

UPDATE

I am using PHP 5.4.4

There was a bug reported regarding this issue in the previous version of php ie below 5.3 and it was told that this issue has been solved in the versions above 5.3. Is there any change in the php.ini that we need to make change to enable. I searched but did not get the answer i expected

Please Help

  • 写回答

2条回答 默认 最新

  • duanlu0559 2012-11-04 17:46
    关注

    use CURL:

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, 'http:\\www.somesite.com\somefile.html'); 
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);
    $data = curl_exec($ch);
    curl_close($ch);
    

    curl_exec($ch) will return FALSE if no file is present or the actual data on success

    However:

    You'd better bind your shared folder to a logical hard drive with

    net use E: \\servername\shareddirectory 
    

    doing this will allow you to access your remote file as it were on a local disk (say E:).

    file_exists() should work if you give the "local" path E:\filepath\filename

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 请问有用MZmine处理 “Waters SYNAPT G2-Si QTOF质谱仪在MSE模式下采集的非靶向数据” 的分析教程吗
  • ¥50 opencv4nodejs 如何安装
  • ¥15 adb push异常 adb: error: 1409-byte write failed: Invalid argument
  • ¥15 nginx反向代理获取ip,java获取真实ip
  • ¥15 eda:门禁系统设计
  • ¥50 如何使用js去调用vscode-js-debugger的方法去调试网页
  • ¥15 376.1电表主站通信协议下发指令全被否认问题
  • ¥15 物体双站RCS和其组成阵列后的双站RCS关系验证
  • ¥15 复杂网络,变滞后传递熵,FDA
  • ¥20 csv格式数据集预处理及模型选择