【问题标题】:Display the image files from the storage显示存储中的图像文件
【发布时间】: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);
    }
});

但似乎无法正常工作,就像图像未显示一样,它无法从“存储”中检索图像。有什么帮助,有什么想法吗?

【问题讨论】:

标签: php laravel laravel-5.3


【解决方案1】:

我已经想通了,我只是用

//path for image from the storage
Route::get('/app/system/sale-items/item/{username}/{item_id}/{image}', function($username,$item_id,$image)
{
    $path = storage_path().'/app/public/'.$username.'/'.$item_id.'/'. $image;
    if (file_exists($path)) { 
        return Response::download($path);
    }
});

【讨论】:

    猜你喜欢
    • 2017-09-03
    • 1970-01-01
    • 2020-12-19
    • 2012-12-02
    • 1970-01-01
    • 2016-10-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多