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条)

报告相同问题?

悬赏问题

  • ¥120 计算机网络的新校区组网设计
  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 海浪数据 南海地区海况数据,波浪数据
  • ¥20 软件测试决策法疑问求解答
  • ¥15 win11 23H2删除推荐的项目,支持注册表等
  • ¥15 matlab 用yalmip搭建模型,cplex求解,线性化处理的方法
  • ¥15 qt6.6.3 基于百度云的语音识别 不会改
  • ¥15 关于#目标检测#的问题:大概就是类似后台自动检测某下架商品的库存,在他监测到该商品上架并且可以购买的瞬间点击立即购买下单
  • ¥15 神经网络怎么把隐含层变量融合到损失函数中?