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

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

图片转代码服务由CSDN问答提供 功能建议

我遇到的问题是我能够链接到http服务器中存在的文件或 ftp服务器..但我无法链接到文件服务器中存在的文件..

即更清楚.. 如果URL是 http: //serverpath.com/images/image.jpg ftp://serverpath.com/images/image.jpg file_exists 函数的远程路径 给出 true 值,但是如果给出一个文件服务器路径,就像 // serverpath / public / images / image.jpg 那样的 file_exists function提供 false 值。

UPDATE

我使用的是PHP 5.4 .4

在上一版本的php中有关于此问题的报告错误,即低于5.3,并且有人告诉我这个问题已在5.3版本中得到解决。 php.ini中是否有任何更改需要进行更改才能启用。 我搜索但没有得到我预期的答案

请帮助

  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

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

    已采纳该答案
    打赏 评论
  • doupeng8494 2012-11-04 17:48

    Your php.ini allow_url_fopen is on?

    打赏 评论

相关推荐 更多相似问题