Laravel存储返回FileNotFoundException但文件存在 [英] Laravel storage returns FileNotFoundException But file exists
本文介绍了Laravel存储返回FileNotFoundException但文件存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在laravel 6中读取文件内容,该文件已经存在,但是laravel返回未找到异常.
I want read file content in laravel 6, the file already exists but laravel return not found exception.
这是我的日志文件目录:
/var/www/html/myLaravelLab/storage/logs/laravel-2019-10-14.log
This is my logs files directory:
/var/www/html/myLaravelLab/storage/logs/laravel-2019-10-14.log
$contents = Storage::get(storage_path('logs/laravel-2019-10-14.log'));
Laravel返回此错误:Illuminate\Contracts\Filesystem\FileNotFoundException
Laravel return this error: Illuminate\Contracts\Filesystem\FileNotFoundException
但是文件已经存在!
我想读取文件内容.
Laravel版本:6.2.0 -PHP版本:7.2.19
Laravel Version: 6.2.0 - PHP Version: 7.2.19
推荐答案
在config/filesystems.php
中添加新磁盘logs
:
'disks' => [
'logs' => [
'driver' => 'local',
'root' => storage_path('logs'),
],
// orher disks...
现在您可以获取日志文件:
Now you can get log files:
Storage::disk('logs')->get('laravel-2019-10-14.log');
这篇关于Laravel存储返回FileNotFoundException但文件存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文