Yasen Sayed
Published in : 2022-03-06
I am trying to delete a photo from my project's public folder before updating another photo. My code looks like this:
if(File::exist( $employee->avatar)){ //$employee->avatar looks /uploads/avatars/1646546082.jpg and it exist in folder File::delete($employee->avatar); }
This is not working in my case. If I comment on this code then another photo-updated without deleting perfectly. How can I solve the issue!
Join our community and get the chance to solve your code issues & share your opinion with us
Sign up Now
Rakshit Date : 2022-03-06
Best answers
34
Best answers
34
If your file is existing to the mentioned directory, try below code, it will work.
Here, PHP Unlink function will work for you.
Try it, It will work for you.
Reference: PHP Unlink function - w3schools.
Eslam Zedan Date : 2022-03-06
Best answers
8
Best answers
8
Try unlink function