How to Delete Directory in Laravel ?

Share Me
  •  
  •  
  •  
  • 1
  •  
  •  
  •  
  •  
  •  
  •  
  •  
    1
    Share

Hi Dev’s,
Today now on this article, i will teach you how can we remove a folder in Laravel 8. So we can delete directory then we use deleteDirectory() also with File object. Here i will show you How to Delete Directory in Laravel 8.

Now we can get our delete folder path then after we use our get path in this function.

So now this method will return true if it succeeds, false if it fails.

Example for Laravel

First need to create a folder like public/test/demo.

public function index()
{
    $folderPath = public_path('test');

    $dd = File::deleteDirectory($folderPath);

    dd($dd);
}

it will return true if this method is success, it will return false if this method fails.

Example for PHP

public function index()
{
    $folderPath = public_path('test');

    $dd = rmdir($folderPath);

    dd($dd);
}

it will return true if this method is success, it will return false if this method fails.

Read Also : How to get current route in laravel ?

Thanks for read. I hope it help you. For more you can follow us on facebook

About code chef

My name is Shahriar sagor. I'm a developer. I live in Bangladesh and I love to write tutorials and tips that will help to other Developer's. I am a big fan of PHP, Javascript, JQuery, Laravel, Codeigniter, VueJS, AngularJS and Bootstrap from the early stage.

View all posts by code chef →