Categories

Friday, April 26, 2024
#919814419350 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

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

 

 

therichpost
the authortherichpost
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 14, Angular 15, Angular 16, Angular 17, Bootstrap 5, Nodejs, Laravel, Codeigniter, Shopify, Squarespace, jQuery, Google Map Api, Vuejs, Reactjs, Big commerce etc.

Leave a Reply

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