首页 > 解决方案 > View 不显示 Laravel 中存储的图像

问题描述

我正在尝试使用下面的代码在视图上显示我的 storage/app/livros 文件夹中的所有图像,但我得到了这个就像我什么都没有。我怎样才能显示这些图像?

@extends('layouts.app_cad_livros')
@section('content')
    <div class="textocs">
        <br>
        <h3>LIVROS</h3>
    </div>
    <div class="card_livro">
        @foreach($livro as $mostra)
            {{$mostra->users_id}}

            <img src="{{ url("storage/app/livros{$mostra->image}") }}"
                 style="max-width=100px;">

            TÍTULO   {{$mostra->namel}}<br>
            AUTOR {{$mostra->autor}}<br>
            EDITORA {{$mostra->editora}}<br>
            CATEGORIA {{$mostra->categoria}}<br>
            CLASSIFICAÇÃO {{$mostra->classificação}}<br>
            DESCRIÇÃO {{$mostra->descricao}}<br>
            CAPA {{$mostra->image}}<br>
        @endforeach
    </div>
    <a href="{{ url('/alugar', $mostra->users_id)}}">
        <button class="btn btn-primary">quero alugar</button>
    </a>
@endsection

这是

<img src="{{ url("storage/{$mostra->image}") }}"  style="max-width=100px;">

标签: phplaravellaravel-8

解决方案


您需要运行以下命令:

php artisan storage:link

并访问图像:

 asset('storage/app/path/to/image')

尝试这个

asset('storage/app/livros/'.$mostra->image.')

或者

asset('storage/app/livros/{$mostra->image}')

您可以从这里获得更多信息


推荐阅读