I get the issue in my code What I want: after clicking on the export button, one CSVfile would be automatic download from the browser.
but it only displays the data in network tab in inspect element but not downloading.
public function Exportcsv(Request $recuestdata) {
$headers = array(
"Content-type" => "text/csv",
"Content-Disposition" => "attachment; filename=file.csv",
"Pragma" => "no-cache",
"Cache-Control" => "must-revalidate, post-check=0, pre-check=0",
"Expires" => "0"
);
$filename = "order";
$output = fopen($filename, 'w+');
$data=json_decode($recuestdata['row']);
foreach ($data as $line) {
fputcsv($output, $line);
}
return Response::download($filename, 'order.csv', $headers);
}
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire