Laravel 6 Delete Directory Example

Laravel 6 , Laravel

Nicesnippets

16274

26-09-2019


Hi Dev,

In this article, i will show you how to remove folder in Laravel 6.you can delete directory then use deleteDirectory() with File object.

You can get your delete folder path thenafter you use your get path in function.

The method will return true if it succeeds, false if it fails.

Example for Laravel


First you can create folder public/test/demo.

public function index()

{

$folderPath = public_path('test');

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

dd($dd);

}

If return true this method success, return false this method fails.

Example for PHP

public function index()

{

$folderPath = public_path('test');

$dd = rmdir($folderPath);

dd($dd);

}

If return true this method success, return false this method fails.

It will help you....


Recommended Posts