【发布时间】:2017-02-28 12:33:25
【问题描述】:
我想显示存储在 Lumen 项目公用文件夹中的图像。 但是我在浏览器中显示时找不到 404。
我已经创建了资产 url 助手:
if (!function_exists('urlGenerator')) {
/**
* @return \Laravel\Lumen\Routing\UrlGenerator
*/
function urlGenerator() {
return new \Laravel\Lumen\Routing\UrlGenerator(app());
}
}
if (!function_exists('asset')) {
/**
* @param $path
* @param bool $secured
*
* @return string
*/
function asset($path, $secured = false) {
return urlGenerator()->asset($path, $secured);
}
}
这就是我如何称呼图片网址:
asset('public/uploads/images/product/') . $product->image
为什么当我尝试调用公用文件夹中的图像时,流明指的是路由?
【问题讨论】:
-
您确定在
asset('public/uploads/images/product/') . $product->image中需要public吗? -
哦,好的,已经解决了,谢谢
-
请您与我分享您的代码保存图像并获取网址