代码之家  ›  专栏  ›  技术社区  ›  Mihai

在laravel 7中显示图像

  •  0
  • Mihai  · 技术社区  · 5 年前

    我用存储图像

    $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

    1 回复  |  直到 5 年前
        1
  •  1
  •   Jems    5 年前

    而不是使用 url ,更好用 asset 检索资产

    public 你的前缀 store() ,它将使用 config/filesystems.php . 路径将从 default disks .

    Asset vs Url

    <img src="{{asset('/storage/' . $cat->picture)}}" class="img-thumbnail" alt="Responsive image">
    
    推荐文章