【发布时间】:2016-11-06 17:21:56
【问题描述】:
我使用的是 Laravel 5.3,在将文件图像从 Laravel Storage 渲染到我的 html/blade 时遇到问题。
我的 filesystems.php 默认驱动
'default' => 'public'
如何将“存储”中的文件图像渲染到 view/html/blade
我试过了,
//path for image from the storage
Route::get('/app/system/sale-items/item/{username}/{item_id}/{image}', function($image,$item_id,$username)
{
$path = storage_path().'/app/public/'.$username.'/'.$item_id.'/'. $image;
if (file_exists($path)) {
return Response::download($path);
}
});
但似乎无法正常工作,就像图像未显示一样,它无法从“存储”中检索图像。有什么帮助,有什么想法吗?
【问题讨论】:
-
尝试使用
storage_path()helper laravel.com/docs/5.3/helpers#method-storage-path -
试试这样的 Route::get('images/{filename}', function ($filename) { return Image::make(storage_path() . '/' . $filename)->响应();});
标签: php laravel laravel-5.3