@foreach ($profiles as $profile)
<tr>
<td>{{ $profile->id }}</td>
<td>{{ $profile->email }}</td>
<td>{{ $profile->name }}</td>
<td>{{ $profile->age }}</td>
<td>{{ $profile->gender }}</td>
<td>{{ $profile->position }}</td>
<td>{{ $profile->department }}</td>
<td>{{ $profile->phone_number }}</td>
<td>
@if ($profile->images)
** <img src="{{ asset('storage/app/public/'.$profile->images) }}" alt="Profile Image"
style="max-width: 50px; border-radius: 50%;">**
@else
No Image
@endif
</td>
字符串
我已经尝试在资产中使用URL,但它根本不起作用,我已经使存储文件夹变短,但它对我没有任何帮助
3条答案
按热度按时间lnvxswe21#
我认为你没有正确地将它与资产和前缀联系起来。尝试
它将在public/storage文件夹中查找映像,您可以在其中定义自己的映像文件夹
字符串
cl25kdpy2#
请检查以下步骤:
1.尝试保存图像位置的绝对而不是相对的URL位置在这种情况下,你应该只是把图像的URL位置指令
字符串
1.如果你想在相对模式下保存位置,首先在laravel中检查存储是否连接到你项目,你可以用途:
php artisan storage:link
在Linux中,您可以用途:
ln -s /storagelocation public/storage
然后用你的代码显示img
型
46scxncf3#
你可以检查这些东西:
1.检查
.env
文件和APP_URL
值:它应该是https://[yourwebsite.com]
-有些人忘记将其从默认的localhost
更改,或者提供错误的URL和额外的文件夹/子域1.如果您在
storage/app/public
中存储图像,请检查您是否已运行php artisan storage:link
成功(因此,没有发生错误)以创建符号链接。1.检查您的Web服务器根文件夹是否成功指向Laravel项目的
/public
文件夹。1.然后,您可以使用
asset('storage/'.$profile->images)
调用这些storage/app/public
图像查看这里的文档:https://laravel.com/docs/10.x/filesystem#the-public-disk
顺便说一下,我会将变量从
images
重命名为image
,因为它似乎是一个单一的图像,可能会被未来的开发人员误解。