Теперь на лезвии «Редактировать профиль» мне нужно показать загруженное изображение аватара пользователя, которое загружается и хранятся в каталоге корневого проекта: < /p>
/home/myuser/domain.com/storage/app/private/public/users/{userId}/{filename}
Я сделал маршрут, как это:
Route::get('/private-file/{type}/{userId}/{filename}', function ($type, $userId, $filename) {
$allowedTypes = ['users', 'members'];
if (!in_array($type, $allowedTypes)) {
abort(404);
}
$mainStoragePath = '/home/pachim/ino-official.org/storage/app/private/public';
$path = $mainStoragePath . "/{$type}/{$userId}/{$filename}";
if (!file_exists($path)) {
abort(404);
}
$mimeType = mime_content_type($path);
return response()->file($path, ['Content-Type' => $mimeType]);
})->name('private.file');
< /code>
И он работает, и покажите изображение Аватара пользователя как: < /p>
https://profile.domain.com/private-file ... 8vtLYu.png
Но в лезвии изображение не отображается, несмотря на правильный источник, который доступен к настоящему времени:
Profile Picture
@php
// Default placeholders if no images
$defaultAvatar = asset('/assets/img/profile.png');
$defaultPassport = asset('assets/img/passport-placeholder.jpg');
// Build URLs using your new route if avatar/passport_photo exist
$avatarUrl = $user->avatar
? url('user-image/' . $user->avatar)
: $defaultAvatar;
$photoUrl = $detail?->passport_photo
? url('user-image/' . $detail->passport_photo)
: $defaultPassport;
@endphp
@error('avatar')
{{ $message }}
@enderror
Accepted: JPG, PNG. Max size: 2MB
Подробнее здесь: https://stackoverflow.com/questions/797 ... ns-200-but
Мобильная версия