Note to Self: Using file_exists() with Laravel 3

“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: ';

		echo '<p> vardump of file_exists with filename: '; 

MyUsr and MyAccnt are Laravel models. You can also swap in

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)”.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s