加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

php – 在laravel 5.2中的路径找不到文件

发布时间:2020-12-14 19:35:05 所属栏目:大数据 来源:网络整理
导读:我在public / badges目录中有一个名为1.png的图像 – 我试图在laravel中使用存储库,但即使文件确实存在于该位置,仍会出现以下错误: //错误 FileNotFoundException in Filesystem.php line 381:File not found at path: Users/gk/Sites/mysite/public/badges
我在public / badges目录中有一个名为1.png的图像 – 我试图在laravel中使用存储库,但即使文件确实存在于该位置,仍会出现以下错误:

//错误

FileNotFoundException in Filesystem.php line 381:
File not found at path: Users/gk/Sites/mysite/public/badges/1.png

//代码

$filePath = 'badges/1.png';
$path = public_path()."/".$filePath
Storage::disk('local')->get($path);
dd($contents);

解决方法

表格Laravel 5.2文件:

When using the local driver,note that all file operations are relative to the root directory defined in your configuration file. By default,this value is set to the storage/app directory.

所以你正在寻找文件:storage / app / Users / gk / Sites / mysite / public / badges / 1.png

错误很混乱.

[更新]

添加到config / filesystems.php

'disks' => [

    //... 

    'local_public' => [
        'driver' => 'local','root'   => public_path(),],//... 
],

然后

$filePath = 'badges/1.png';
$content = Storage::disk('local_public')->get($filePath);
dd($content);

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读