I want to make files downloadble on click, but it does not work. Here comes my code:
files.html.twig
{% set filepath = asset('bundles/example/files/filename.pdf') %}
<a href="{{ url('_bundle_route_to_download', { 'filepath': filepath }) }}">
<button class="button button-icon button-download">Download</button></a>
controller.php
/**
* @Route("/example/download/{filepath}", name="_bundle_route_to_download")
*/
public function downloadFile($filepath)
{
//...
}
This is the error I get:
No route found for "GET /example/download//bundles/example/files/filename.pdf%3F1418390151
What is wrong about my syntax?