Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

CookieMonster's avatar

laravel- how to read file path from storage?

I have a list of generated receipt (in pdf) that is saved in my storage folder of my project. I want to be able to read from there when I click on it. Right now, it's looks like this:

 <div><a href="{{asset('/public/storage/documents/invoice/'.$purchase->getFormattedNumber().'/'.$purchase->getFormattedNumber().'-receipt.pdf')}}">Receipt</a></div>

When I click on it, it says not found which mean my path is wrong.

If I paste this:

C:\laragon\www\name_project\public\storage\documents\invoice\  0BSN2020000006\ 0BSN2020000006-receipt.pdf

(Ignore the spacing above)

It would be able to access it directly from my local drive. I am unfamiliar with the path system.

What is the helper method that I can use to access it and also when I deploy it to a staging server?

0 likes
1 reply

Please or to participate in this conversation.