laravel文件存儲Storage

use Illuminate\Support\Facades\Storage;


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

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

 

$fileStr = Storage::disk('public')->get($fileName);//獲取文件內容
//獲取目錄文件,兩個返回值有差異,第一個帶public
$files = Storage::allFiles('public');
$files = Storage::disk('public')->allFiles();

 

 

可參考:https://d.laravel-china.org/docs/5.5/filesystemphp

相關文章
相關標籤/搜索