“path(‘www’)” seems to work, where path(‘www’) is a function that returns the relevant local file system path (/User/path_to_project/main_project_dir/www/home/images/testphoto.jpg) and not my localhost path (http://localhost/www/home/images/testphoto.jpg):
$filename = path('www') . MyUsr::find(MyAccnt::id())->user_image(); echo '<p> vardump of filename: '; var_dump($filename); echo '<p> vardump of file_exists with filename: '; var_dump(file_exists($filename));
MyUsr and MyAccnt are Laravel models. You can also swap in
var_dump( File::exists($filename) );
for
var_dump(file_exists($filename));
Using a relative path or $_SERVER[‘DOCUMENT_ROOT’] didn’t work for me, the var_dump would always return “bool(false)”.