如何在 blade 视图中显示存储在外部存储器中的图像?
How to display in a blade view images stored in a external storage?
我想使用外部存储来保存我的图像并在 blade
中显示它们
我创建了一个自定义文件系统,其中存在我的图像(在本例中为我的文档文件夹),但是当我尝试在 blade 中显示图像时,它们没有显示
我的自定义文件系统:
'custom' => [
'driver' => 'local',
'root' => 'C:/Users/my name/Documents',
'url' => 'http://localhost/halo/public/prueba',
'visibility' => 'public',
],
简单blade
<img src="{{ Storage::disk('custom')->url("pantalla.png") }}">
和路线
Route::get('/prueba', function () {
return view('prueba');
});
http://localhost/halo/public/prueba 显示损坏的图像图标
source-code 显示:
<img src="C:/Users/my name/Documents/pantalla.png">
使用此代码,图像显示在 html 视图中,使用 blade 文件,但图像来自特定的项目目录。假设存储在 uploads/admin 目录中的图像和图像来自 uing session 或者我们可以说 middleware
在 blade 文件中添加这些代码
<img src="{{url('/uploads/admin/'.\Session::get('admin')->profile_image)}}" alt="profile image">
我想使用外部存储来保存我的图像并在 blade
中显示它们我创建了一个自定义文件系统,其中存在我的图像(在本例中为我的文档文件夹),但是当我尝试在 blade 中显示图像时,它们没有显示
我的自定义文件系统:
'custom' => [
'driver' => 'local',
'root' => 'C:/Users/my name/Documents',
'url' => 'http://localhost/halo/public/prueba',
'visibility' => 'public',
],
简单blade
<img src="{{ Storage::disk('custom')->url("pantalla.png") }}">
和路线
Route::get('/prueba', function () {
return view('prueba');
});
http://localhost/halo/public/prueba 显示损坏的图像图标
source-code 显示:
<img src="C:/Users/my name/Documents/pantalla.png">
使用此代码,图像显示在 html 视图中,使用 blade 文件,但图像来自特定的项目目录。假设存储在 uploads/admin 目录中的图像和图像来自 uing session 或者我们可以说 middleware
在 blade 文件中添加这些代码
<img src="{{url('/uploads/admin/'.\Session::get('admin')->profile_image)}}" alt="profile image">