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 用windows做服务的同志有吗
  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图