Php 拉维存储图像

Php 拉维存储图像,php,html,laravel,web,Php,Html,Laravel,Web,我的图像工作正常,但现在我的存储目录有问题 在他们来这里之前: 但现在他们要走到这里: 我的代码配置文件控制器: if($r->hasFile('profile_avatar')){ Auth::user()->update([ 'profile_avatar' => $r->profile_avatar->store('public/avatars') ]);

我的图像工作正常,但现在我的存储目录有问题

在他们来这里之前:

但现在他们要走到这里:

我的代码配置文件控制器:

        if($r->hasFile('profile_avatar')){
            Auth::user()->update([
            'profile_avatar' => $r->profile_avatar->store('public/avatars')
            ]);
        }

        if($r->hasFile('banner')){
            Auth::user()->profile()->update([
            'banner' => $r->banner->store('public/avatars')
            ]);
        }

        Session::flash('success', 'Perfil Atualizado com Sucesso!');
        return redirect()->back();
    }

这是工作之前,但现在它没有显示任何图片

 <img src="{{ Storage::url($user->profile_avatar) }}" width="400px" height="400px" style="border-radius: 50%; display: inline-block" alt="" class="unselectable">
profile\u avatar)}“width=“400px”height=“400px”style=“边界半径:50%;显示:内联块“alt=”“class=”不可选择“>

使用laravel中的资产修复问题,例如:

{{asset('avatars/imagename.png')}}

而不是:在显示图片时使用存储方法。

好吧,这是因为您使用了错误的方法

如果确实要定义要在其中存储图像文件的磁盘,则必须将磁盘名作为
\lighting\Http\UploadedFile->store(…)
方法的第二个参数传递

//而不是:❌
'profile\u avatar'=>$r->profile\u avatar->store('public/avatars'))
//使用以下命令:✅
'profile\u avatar'=>$r->file('profile\u avatar')->商店('avatars','public')

//而不是:❌
'banner'=>$r->banner->store('public/avatars'))
//使用以下命令:✅
'banner'=>$r->file('banner')->store('avatars','public'))

$r->profile\u avatar->store('public/avatar'))$r有这个存储功能吗?似乎应该控制保存目录签出:检查config/filesystem.php文件以配置默认的存储驱动程序及其路径。我相信这不是问题所在。他的方法也很有效,因为他已经在
public/storage
中定义了一个符号链接,指向
storage/app/public
目录。阅读更多信息: