سؤال

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

هل كانت مفيدة؟

المحلول

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

نصائح أخرى

Your php.ini allow_url_fopen is on?

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top