删除laravel中的所有存储文件

时间:2020-11-04 12:13:12

标签: laravel

我需要清除所有storage文件,我可以尝试这样做:

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

这是我的存储空间:

enter image description here

我该怎么清除所有填充物?

2 个答案:

答案 0 :(得分:1)

您可以这样做:

use Illuminate\Support\Facades\File;

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


答案 1 :(得分:0)

您可以尝试使用此代码

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