Iftakharul Alam
Iftakharul Alam

Reputation: 3321

Laravel 5 public folder asset management

I have a file stored in public/files/sample.pdf. When I want to download the file using <a href="/public/files/sample.pdf">Download</a>. It says not found. What will be the correct path. Thank you.

Upvotes: 1

Views: 267

Answers (3)

Larry
Larry

Reputation: 93

If you're really looking for a download response when clicking the link, you should have the URL link to a controller method.

<a href="{{ url('route/to/method') }}">

Now in the controller method

return response()->download(public_path('files/sample.pdf'));

Laravel responses

Upvotes: 1

Ire
Ire

Reputation: 279

You should apply url function instead of paste the directory directly.

<a href="{{url('/files/sample.pdf'}}">Download</a>

Upvotes: 2

Gabriel Moretti
Gabriel Moretti

Reputation: 676

/files/sample.pdf

You can always use

href="{{asset('files/sample.pdf')}}"

It will be easier

Upvotes: 2

Related Questions