gpt4 book ai didi

php - Laravel:加载存储在 'storage' 文件夹中的图像

转载 作者:行者123 更新时间:2023-11-29 03:23:58 26 4
gpt4 key购买 nike

我正在尝试显示存储在“存储”文件夹中的图像,以保护图像文件夹。我应该如何为 2 个参数执行此操作,下面的代码效果不佳:

路线:

Route::get('img/users/{id}/logo/{image}', function($id = null, $image = null)
{
$path = storage_path().'/img/profils/'.$id.'/logo/'.$image;
if (file_exists($path)) {
return Response::download($path);
}
});

查看:

src="{!!asset('img/users/'.$user->id.'/logo/'.$user->imagelogo)!!}"

最佳答案

我已经这样做了,但不是用你的方式。我所做的是,
将图像保存在 public 中文件夹。
然后创建了自定义css并使用

.your div tag id {
width: 100%; //px you need
height: auto;
padding: 100px 0;
text-align: center;
color: #fff;
background: url(../your image.jpg);
background-color: #000;
}

我认为在 <panel> 中使用它会给你一个解决方案。

关于php - Laravel:加载存储在 'storage' 文件夹中的图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39317068/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com