Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

What is the counterpart of:

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

using Storage:: in Laravel 5.1 ?

Anyone?

like image 976
Chriz74 Avatar asked May 10 '16 09:05

Chriz74


People also ask

Where is storage folder in Laravel?

Laravel's filesystem configuration file is located at config/filesystems.php . Within this file, you may configure all of your filesystem "disks". Each disk represents a particular storage driver and storage location.

How can I get storage path in Laravel 8?

You can use the storage_path(); function to get storage folder path.

How do I delete files from storage folder in Laravel?

One way to delete a file from the public directory in Laravel is to use the Storage facade. To delete a file, you will need to follow the following steps: Step 1: Check to ensure that the folder and file exist. Step 2: Delete the required file.

How do I save to storage folder in Laravel?

Now, if you need to change the directory and store into the storage folder directly, you need to change something in the filesystems. php file. 'local' => [ 'driver' => 'local', 'root' => storage_path('app'), ], Here, this line of code 'root' => storage_path('app'), responsible to define where to store.


1 Answers

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'); 
like image 131
prava Avatar answered Oct 07 '22 05:10

prava