How to check if file exists or not in Laravel?
Nowdays laravel framework is popular framework in PHP Language. So, if you required to check if file is exists or not in given path then you can check eisily. Normally we always need to check if image exists, check if pdf file exists, check if docs exists or not etc. I give you two way to check file is Exists or not. one using file_exists() and second one using File facade of laravel 5. it's better if you preffer File facade example. So, let's see and implement:
Example 1:
if(file_exists(public_path('images/1461177230.jpg'))){
dd('File is exists.');
}else{
dd('File is not exists.');
}
Example 2:
if(File::exists(public_path('images/1461177230.jpg'))){
dd('File is exists.');
}else{
dd('File is not exists.');
}

Hardik Savani
I'm a full-stack developer, entrepreneur and owner of Aatman Infotech. I live in India and I love to write tutorials and tips that can help to other artisan. I am a big fan of PHP, Laravel, Angular, Vue, Node, Javascript, JQuery, Codeigniter and Bootstrap from the early stage. I believe in Hardworking and Consistency.