I have a requirement of after user clicks on a link to download a csv file then that csv file has to be downloaded located at our application path. I have written code for it but its not working getting routing related error it is not going inside of the specified controller method. my code is
<a href="/alerts/download">Download</a>
My Controller:
public function getDownload(Request $request)
{
//CSV file is stored under project/public/download/sample.csv
$file= public_path(). "/download/sample.csv";
return response()->download($file);
}
My Route
Route::get('alerts/download', 'AlertsController@getDownload');
I googled and tried some solutions but not working though. Any Help would be appreciated. Thanks.