0

On a page I have a link:

<a href="{{ route('downloadWirebird',[$mag->id]) }}" target="_blank" title="download PDF">@fa('download')</a>&nbsp;&nbsp;

and in the web.php I have:

Route::get('downloadWirebird/{id}','FrontController@downloadWirebird')->name('downloadWirebird');

In FrontController I have:

public function downloadWirebird($id)
                {
                  $wbd = Wirebird::find($id);
                  $fileName = asset('Wirebird')."/".$wbd->PDF;
                  $headers = ['Content-Type: application/pdf'];
                  return response()->download($fileName, $headers);
                }

All the paths are correct but when I click on the link absolutely nothing happens.

Jim
  • 596
  • 1
  • 10
  • 36
  • To download a file use the following code: https://stackoverflow.com/a/10615916/3254405 – boateng Oct 30 '17 at 16:02
  • I really was looking for the Laravel 5.5 answer – Jim Oct 30 '17 at 16:28
  • True, then may be your notation is wrong the way you put column separator in headers but an arrow after response(), try sticking to either columns or arrows: https://stackoverflow.com/a/20415796/3254405 – boateng Oct 30 '17 at 16:54
  • Have amend the controller to $wbd = Wirebird::find($id); $file= public_path()."/Wirebird"; $headers = array( 'Content-Type: application/pdf', ); return response()->download($file, $wbd[0]['PDF'], $headers); but still nothing works – Jim Oct 30 '17 at 17:21
  • Try to simplify, so get rid of Wirebird thing (not sure what it is), something like this example and include a facade library as it says, or just hard code a full path for testing, then check with Fiddler for raw headers: https://stackoverflow.com/a/38821002/3254405 – boateng Oct 30 '17 at 18:04
  • Can you please share a dd($wbd) ? What does $wbd->PDF print ? – tintinboss Nov 01 '17 at 13:40

0 Answers0