如何在网络浏览器中以 laravel 流明查看上传的图像?

how to see uploaded image in web browser in laravel lumen?

你能帮我解决这个愚蠢的问题吗:( 我已经在 project-root/storage/products 下的 laravel lumen 中上传了图片 但是我不知道如何在浏览器中检查上传的图片,我的存储文件夹在 public 目录之外,我已经试过了

http://192.168.11.102:8000/storage/products/upc_1443002080.jpg
http://192.168.11.102:8000/index.php/storage/products/upc_1443002080.jpg

但我得到了 - 抱歉,您要查找的页面无法找到 found.Can 请帮帮我?

更新 如您所说,我创建了这样的路线 -

$app->get('products/{filename}', function ($filename) {
$path = storage_path().'/products/'.$filename;

if (file_exists($path)) {
    return Response::download($path);
}});

但是当我点击 http://192.168.11.102:8000/storage/products/upc_1443002080.jpg 它正在下载文件而不是显示在浏览器中。你有什么主意吗? 我在 Response::download 函数中有以下代码 -

public static function download($file, $name = null, array $headers = [], $disposition = 'attachment')
{
    $response = new BinaryFileResponse($file, 200, $headers, true, $disposition);
    if (! is_null($name)) {
        return $response->setContentDisposition($disposition, $name, str_replace('%', '', Str::ascii($name)));
    }
    return $response;
}

存储目录中存储的文件受到保护。文档根目录是 /public。要在浏览器中查看上传的项目,您需要创建一个接受文件名的路由,然后控制器将获取该文件。