将心比心,方得人心~

laravel文件存储Storage

周洲 2019-10-08 16:29:28

use Illuminate\Support\Facades\Storage;


//建立目录
Storage::disk('public')->makeDirectory(date('Y-m'));

//存文件 public为config/filesystems.php存的配置
$bool = Storage::disk('public')->put($filename, f ile_get_contents($realPath));

获取内容

$fileStr = Storage::disk('public')->get($fileName);

获取目录文件,两个返回值有差别,第一个带public

$files = Storage::allFiles('public');
$files = Storage::disk('public')->allFiles();

参考地址:

https://learnku.com/docs/laravel/6.x/filesystem/5163


打赏

『微信打赏』

Tag标签Storage 

我是有底线的