Laravel中图像路径中的正斜杠问题

问题描述 投票:2回答:2

在我的Laravel网站上,图像名称是

images/campaign/4965d649233e1436ece21804ff4eb62b.jpeg

实际图像路径是http://localhost/fund/storage/app/images/campaign/4965d649233e1436ece21804ff4eb62b.jpeg

但是在我的刀片模板中,当我使用此路径时,它会自动转换为http://localhost/fund/storage/app/images%2Fcampaign%2F4965d649233e1436ece21804ff4eb62b.jpeg

这就是我的图像没有显示的原因。

在刀片模板中输入src代码

src="{{url('/storage/app',$response->large_image)}}" 

为什么/会自动被%2F取代以及如何解决它?

有人帮忙吗?

php laravel laravel-5.5 laravel-blade
2个回答
4
投票

将刀片更改为以下内容:

src="{{url('/storage/app/'.$response->large_image)}}"

我已经将逗号更改为一个点,它将图像的路径附加到/storage/app部分,因此它不会编码最后一部分。


0
投票

当您使用双引号而不是单引号时,无需使用连接

src='{{url("/storage/app/$response->large_image")}}'
© www.soinside.com 2019 - 2024. All rights reserved.