I'm trying to delete all the files in a folder that have the extension .jpg is possible using Storage :: delete ('file.jpg');
I'm trying to delete all the files in a folder that have the extension .jpg is possible using Storage :: delete ('file.jpg');
According to Laravel's official documentation, yes.
In English: Deleting files
In Spanish (this part is not yet translated): Deleting files
From the original documentation:
Deleting Files
The delete method accepts a single filename or an array of files to remove from the disk:
use Illuminate\Support\Facades\Storage; Storage::delete('file.jpg'); Storage::delete(['file1.jpg', 'file2.jpg']);
If necessary, you may specify the disk that the file should be deleted from:
use Illuminate\Support\Facades\Storage; Storage::disk('s3')->delete('folder_path/file_name.jpg');
But to delete ALL the files with a certain suffix you have to do the following:
* Thanks to the Pikoh's comment
File::delete(File::glob('path/*.jpg'));