我用存储图像
$cat->picture = $request->file('catpicture')->store('public/catpictures'); $cat->save();
我创造了符号链接
php artisan storage:link The [/var/www/html/project/public/storage] link has been connected to [/var/www/html/project/storage/app/public]. The links have been created.
我的刀刃上有:
<img src="{{url($cat->picture)}}" class="img-thumbnail" alt="Responsive image">
即“公共/catpictures/igtx81oyvymthuztydfepgvfzgaleew1FmHpas.png"
图像没有显示,我遗漏了什么? src是 http://127.0.0.1:8000/public/catpictures/IgTx81OYKVymthuzTydFVepGvFZGALeeW1FmHpas.png
而不是使用 url ,更好用 asset 检索资产
url
asset
public 你的前缀 store() ,它将使用 config/filesystems.php . 路径将从 default disks .
public
store()
config/filesystems.php
default disks
Asset vs Url
<img src="{{asset('/storage/' . $cat->picture)}}" class="img-thumbnail" alt="Responsive image">