gpt4 book ai didi

Laravel - Public_Path 作为本地系统路径返​​回

转载 作者:行者123 更新时间:2023-12-02 16:41:39 25 4
gpt4 key购买 nike

我有一个奇怪的问题,但我相信可以通过我可能不知道的配置轻松更改。

因此,如果我想访问附件的路径,我在 Blade 中使用以下代码:

{{ $volunteer->photoID->attachment}}

这会返回给我:

public/volunteers/tgjW0GOQTzSEjG7F5Wlq0G9mEdGJ7fE7TLxpKRyn.jpg

但是我试图将图像放入 pdf 中,并且由于加载要求,我必须将 Blade 中的返回格式化为这样:

{{ public_path($volunteer->photoID->attachment)}}

问题是这个返回:

E:\webserver\htdocs\hopin\public\public/volunteers/tgjW0GOQTzSEjG7F5Wlq0G9mEdGJ7fE7TLxpKRyn.jpg

这在 img 元素中不可用。那么我做错了什么吗?或者有更好的方法来创建可用路径吗?

最佳答案

尝试使用realpath输出附件时:

{{ realpath(public_path($volunteer->photoID->attachment)) }}

关于Laravel - Public_Path 作为本地系统路径返​​回,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51471797/

25 4 0