melissa poorkamaly
melissa poorkamaly

Reputation: 27

Remove all storage file in laravel

I am need to clear all my storage files , I am try this :

Route::get('/clear/storage', function () {
        $file = new Filesystem;
        $file->cleanDirectory('storage/app');
        return show_message(true, 'clear successfully');
});

and this is my storage :

enter image description here

how could I do that to clear all fills ?

Upvotes: 0

Views: 136

Answers (2)

Sok Chanty
Sok Chanty

Reputation: 1816

You can do it by this:

use Illuminate\Support\Facades\File;

Route::get('/clear/storage', function () {
    File::cleanDirectory(storage_path('/'));
    return show_message(true, 'clear successfully');
});


Upvotes: 1

Mustafa Goda
Mustafa Goda

Reputation: 109

You can try this code

$getAllFilesInPath = scandir('storage/app');
Storage::delete($getAllFilesInPath);

Upvotes: 0

Related Questions