Laravel Delete Directory from Storage Example

10-Apr-2023

.

Admin

Hi Dev,

In this article, i will show you how to remove folder in Laravel.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....

#Laravel

#Laravel 6