Laravel delete directory from public

You can use Illuminate\Filesystem\Filesystem for this. Laravel provides the File facade for easy access:

File::deleteDirectory(public_path('path/to/folder'));

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


To be accessible by Storage you should define the filesystem name in config/filesystems and be sure to have the right permissions to be able to what you want to do.

Then something like Storage::deleteDirectory($directory); assuming that $directory is something you got properly from the corresponding resource.

Read the docs here


You can use this:

 $path = 'upload/pic/foldername/';
 if (\File::exists($path)) \File::deleteDirectory($path);

foldername is deleting with all files in it.

Tags:

Php

Laravel