Home Laravel Check and Delete Image from Public folder in Laravel

Check and Delete Image from Public folder in Laravel

by therichpost
0 comment
Laravel 7.2 routing with route group auth guard check with prefix

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

 

 

You may also like

Leave a Comment

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