Laravel File Storage删除目录中的所有文件 [英] Laravel File Storage delete all files in directory

查看:1750
本文介绍了Laravel File Storage删除目录中的所有文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以删除特定目录中的所有文件.我正在尝试清除我在storage \ app \ backgrounds中但在 docs 似乎无法删除全部内容.

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');

推荐答案

我不认为这是否是解决此问题的最佳方法.但是我解决了我的电话问题

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

use Illuminate\Filesystem\Filesystem;

然后启动新实例

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

这篇关于Laravel File Storage删除目录中的所有文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆