Sunday, July 12, 2020
therichposts@gmail.com
LaravelLaravl 5.7

Check and Delete Image from Public folder in Laravel

Laravel 7.2 routing with route group auth guard check with prefix

Check and Delete Image from Public folder in Laravel

Views

Hello to all, welcome to therichpost.com. In this post, I will tell you, Check and Delete Image from Public folder in Laravel.

Laravel is the best php mvc framework and also very popular now a days. In this post, I will tell you the code to check image exists in folder and delete the image or any file from the folder with php code.

Here is the working code:

 

1. Here is the code for delete image or any file from the public folder in laravel:

$image_path = public_path().'/img/gallery-images/text.png';
unlink($image_path);

 

2. Here is the code to check image exists in public folder or not:

$file = public_path().'/img/gallery-images/text.png';
if (@getimagesize($file)) {
echo "$file image exists";
}
else
{
echo "$file image does not exists";
}

If you have any query related to this post then please do comment below or ask question.

Thank you,

Jassa Jatt,

TheRichPost

 

 

Ajay Malhotra
the authorAjay Malhotra
Hello to all. Welcome to therichpost.com. Myself Ajay Malhotra and I am freelance full stack developer. I love coding. I know Wordpress, Core php, Angularjs, Angular 2, Angular 6, Angular 7, Angular 8, Angular 9, Angular 10 Nodejs, laravel, Codeigniter, Shopify, Squarespace, Jquery, Google Map Api, Vuejs, Reactjs, Bigcommerce etc.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.