Download Files / Images Laravel 5.2


I tried to download files or images, but I just get this

Sorry, the page you are looking for could not be found. 1/1 NotFoundHttpException in RouteCollection.php line 161:

My route

   Route::get('/download/{$file}' , '[email protected]');

My controller

public function downloadFile($file){
      $pathtoFile = public_path().'images/'.$file;
      return response()->download($pathtoFile);

My sight

<a href='/download/{{$file}}'>Download</a>

Where is my error or is there another way to do it?

asked by Elio 19.07.2016 в 17:26

1 answer


You are incorrectly specifying the mandatory entry parameter in the route, you do not need the $ sign before the parameter name file :

Route::get('/download/{file}' , '[email protected]');

More information in the Laravel documentation: link

answered by 19.07.2016 / 18:28