Hi Dev’s, Today in this article, i will teach you how to remove file from folder using File object in laravel application. Now we can easily delete a file in laravel application. And also we can solved it simply by define the command then delete the file in laravel application. Here i will show you How to delete file in Laravel.
So we are just trying to use File::delete function to delete a file from public path, but always i get the message “File not found at path”.
solution for laravel
/** * Show the application dashboard. * * @return \Illuminate\Contracts\Support\Renderable */ public function index(Request $request) { $file = public_path('img/slider.jpeg'); $img = File::delete($file); dd($img); }
it return true if this method is success, and return false if this method fails.
solution for core php
/** * Show the application dashboard. * * @return \Illuminate\Contracts\Support\Renderable */ public function index(Request $request) { $file = public_path('img/slider.jpeg'); $img = unlink($file); dd($img); }
it return true if this method is success, and return false if this method fails.
Read Also : How to get current URL with parameters in Laravel ?
Thanks for read. I hope it help you. For more you can follow us on facebook