Iftakharul Alam
Iftakharul Alam

Reputation: 3321

Laravel 5 file delete issue

I have a file in public/images/demo.jpg but unable to delete by File::delete(public/images/demo.jpg) in windows. How to solve the issue.

Upvotes: 0

Views: 193

Answers (2)

Hasan Tareque
Hasan Tareque

Reputation: 1741

your path is not a string !!!

The following should work ...

$file_path = public_path().'/images/demo.jpg';

if(File::exists($file_path)){
   File::delete($file_path);
}

Upvotes: 0

baao
baao

Reputation: 73241

Try it with the correct path:

File::delete(public_path('images/demo.jpg'));

Upvotes: 3

Related Questions