Reputation: 5859
I want to know if you do the following in my code below how do you check if the file exists e.g
{
$file = Storage::disks('local')->get($file);
// then test if $file exists
}
Upvotes: 0
Views: 2633
Reputation: 4315
You can check the existence of the file with the code below for your local storage,
$file_exists = Storage::disk('local')->exists($file);
You can read more about storage on Laravel Document at Laravel Filesystem.
Note: in the document you will check disk('s3')
. It depends on what connection we are using defined in config/filesystem.php
(the configuration file for the filesystem in laravel).
OR simply you can use check the condition by
if(Storage::disk('local')->exists($file)) {
}
It will also work for you.
Upvotes: 5