phplaravellaravel-5.5file-storage

Laravel File Storage delete all files in directory


Is there a way to delete all files in specific directory. I'm trying to clear all my files in my created folder backgrounds in storage\app\backgrounds but in docs seems no method for delete all.

Storage::delete('backgrounds\*.jpg');

Solution

  • I don't think if this is the best way to solve this. But I solved mine calling

    use Illuminate\Filesystem\Filesystem;
    

    Then initiate new instance

    $file = new Filesystem;
    $file->cleanDirectory('storage/app/backgrounds');