HDTuto.com

How to delete directory in Laravel 6?



In this example, we will learn how to remove folder with files from storage public folder in laravel 6 application. we can easily delete folder using File or Storage facade in laravel 6 project. i will give you more solution of laravel 6 remove folder from public folder or storage folder.

I will give you more way to delete folder from public folder in laravel 6. you can see i will use File facade to remove folder, Storage facade will use to remove directory from storage in laravel 6 and also i will give you simple code core php to delete folder.

Using File System:

public function deleteFolder()

{

$folderPath = public_path('uploads');

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

dd($response);

}

Using Storage System:

public function removeFolder()

{

$response = Storage::deleteDirectory('uploads');

dd($response);

}

Using Core PHP:

public function removeFolder()

{

$folderPath = public_path('uploads');

$response = rmdir($folderPath);

dd($response);

}

It will help you...




September 28, 2019 | Category : LaravelLaravel 6
Related Posts



Blog Search