php - 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;">
解决方案
您需要运行以下命令:
php artisan storage:link
并访问图像:
asset('storage/app/path/to/image')
尝试这个
asset('storage/app/livros/'.$mostra->image.')
或者
asset('storage/app/livros/{$mostra->image}')
您可以从这里获得更多信息
推荐阅读
- android - 与 AppTheme 冲突我的应用程序无法使用内置的 actionBar,但其中一个库需要 AppTheme 中的 actionBar
- stored-procedures - 使用 Gridview 插入数据,只输入第一行,忽略后续行
- wildfly - 如何修复 Active MQ Wildfly 警告 - 页面文件 000002707.page 在记录号 9 的位置 373,401 处的记录不完整?
- c# - 在 C# 中删除控制台滚动条后留下的空间
- javascript - 密码值返回未定义,但是当使用console.log显示时,用户可以看到
- eclipse - 即使跨 Ubuntu 上的其他窗口,Eclipse CDT 覆盖弹出工具提示消息也不会消失
- firebase - 是否可以删除 currentUser firebase 身份验证用户?
- java - 所有 @Before 和 @After 场景方法都在场景执行之前被调用
- reactjs - 如果填写了 form.item 2,则禁用 form.item 1
- ansible - 如何逃跑?在 Ansible 任务中?