I need to generate PDF documents and have them send by email as well as make them reachable by a link. Sending by email is OK, but I have no idea how to create the link.
Since I use Laravel 4, all links are going through routes.php
.
So how do I create a link to a file at a given directory?
<a href="http://my.domain.org/assets/pdf/file.pdf">Link</a>
will not work, since the route is not known by laravel...
To generate a link to a physical file or directory, that you don't want to run through Laravel's application (e.g. through index.php), use URL::asset()
.
URL::asset('assets/pdf/file.pdf');
This assumes you've created a physical PDF file on your server that you want to link to. If your PDF file is dynamic and generated/retrieved through your Laravel application, you should use URL::to()
, URL::route()
, or similar.
Martin Tale is right, but this is another way of accomplishing the same using Laravel's Blade:
{{ link_to('/assets/pdf/file.pdf', 'Link') }}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With