0

I'm trying to check if a file exists or not in external url.

(My external url is another project's file in my local directory)

The other project folder is mvf. So I'm trying to get it like:

    $url = '//localhost/mvf/assets/img/img.png';

I want to check if this file exists or not for the path above. My code is:

    if(file_exists($url)) {
       echo "exist";
    } else {
       echo "no";
    }

But the above code always returns no eventhough the file exits.

Alireza A2F
  • 519
  • 4
  • 26
VinoCoder
  • 1,133
  • 5
  • 22
  • 45

1 Answers1

0

Try this,absolute path

$url = $_SERVER['DOCUMENT_ROOT'] .'mvf/assets/img/img.png';
//please change this path according to your folder system
if(file_exists($url)) {
   echo "exist";
} else {
   echo "no";
}
M.Hemant
  • 2,345
  • 1
  • 9
  • 14