我试图显示由用户上传的用户化身。该映像正在保存在服务器上,但每当我试图显示它时,它就会产生一个404未找到的错误。
我使用以下方法保存图像:
$path = $request->file('image')->store('avatars');我已经使用php artisan storage:link命令作为文件显示创建了一个符号链接
我的HTML:
@if(config('adminlte.usermenu_image'))
<img src="{{ Auth::user()->adminlte_image() }}"
class="user-image img-circle elevation-2"
alt="{{ Auth::user()->name }}">
@endif我使用Laravel-adminLTE软件包并使用下面的函数将图像URL发送到视图
public function adminlte_image()
{
return Storage::url($this->avatar);
}我的文件夹:

错误:
http://localhost:8000/storage/avatars/S8Npk86Zun9FAYBREgxgOh9Ye6xiHVhyAmm3Vhb1.jpeg 404 (Not Found)filesystems.php:
'disks' => [
'local' => [
'driver' => 'local',
'root' => storage_path('app'),
],
'public' => [
'driver' => 'local',
'root' => storage_path('app/public'),
'url' => env('APP_URL').'/storage',
'visibility' => 'public',
],我已经看过几个关于符号链接的问题了,但是我找不到答案。我很明显遗漏了一些东西,任何帮助都将不胜感激。
发布于 2020-05-28 14:43:31
问题是我把映像存储在错误的磁盘中。我的filesystems.php指向/public目录。我将图像存储在/avatars中。
将路径更改为:
'public' => [
'driver' => 'local',
'root' => storage_path('app/public/avatars'),以及存储方法:
$path = $request->file('imagem')->store('public/avatars');解决了这个问题
https://stackoverflow.com/questions/62066922
复制相似问题