jHannel
jHannel

Reputation: 203

Laravel - Public_Path is Returned as Local System Path

I have an odd issue but I believe could be readily changed with a configuration I might not know about.

So if I want to access the path of an attachment I use the following code in my blade:

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

Which returns me this:

public/volunteers/tgjW0GOQTzSEjG7F5Wlq0G9mEdGJ7fE7TLxpKRyn.jpg

But I am trying to put the image inside of a pdf, and because of the loading requirements, I am having to format the return in the blade as such:

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

The problem is this returns:

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

Which isn't usable in the img element. So is there something I am doing wrong? Or is there a better way of creating the usable path?

Upvotes: 3

Views: 171

Answers (1)

Brian Lee
Brian Lee

Reputation: 18187

Try using realpath when outputting the attachment:

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

Upvotes: 1

Related Questions