In this article, i will show you how to check file is exists or not in folder laravel 6 application. we can easily check file is exists or not in directory using File or Storage facade in laravel 6 project. i will give you simple and more solution of laravel 6 check file is available or not from public folder or storage folder.
I will give you more way to check file is exists or not in public folder in laravel 6. you can see i will use File facade to check file is exists or not, Storage facade will use to check file is exists or not in directory from storage in laravel 6 and also i will give you simple code core php to check file is exists or not.
Using File System:
public function checkFile(Request $request)
{
$path = public_path('upload/itsolutionstuff.png');
$isExists = File::exists($path);
dd($isExists);
}
Using Storage System:
public function checkFile()
{
$isExists = Storage::exists('upload/itsolutionstuff.png');
dd($isExists);
}
Using Core PHP:
public function checkFile()
{
$path = public_path('upload/itsolutionstuff.png');
$isExists = file_exists($path);
dd($isExists);
}
It will help you...
Do you like below Tutorials ?
- Laravel 7.x and 6.x Ajax Multiple Image Upload with Preview Example
- Laravel select with count(*) using db raw example
- PHP Laravel select with join subquery example
- PHP Laravel Ajax Form Submit Example
- How to create events for created/updated/deleted model task in Laravel 5?
- Angular JS Form Validation Example Code
- AngularJS - Confirm Password Validation Example
- Laravel Ajax Request using X-editable bootstrap Plugin Example