how to check if directory exists with Storage:: facade in laravel?

Chriz74 picture Chriz74 · May 10, 2016 · Viewed 55.9k times · Source

What is the counterpart of:

if (!File::exists($path))

using Storage:: in Laravel 5.1 ?

Anyone?

Answer

prava picture prava · May 10, 2016

Try this:

// To check if File exists in Laravel 5.1
$exists = Storage::disk('local')->has('file.jpg');

// To check if File exists in Laravel 5.2
$exists = Storage::disk('local')->exists('file.jpg');