I do not know why but I have tried all the codes in the different sites and they have not worked to me, the file does not download I do not know why I am using this code and it does not download either, the file is created successfully but it does not download I mean there is not any error.
header("Content-type: text/csv");
header("Content-Disposition: attachment; filename=result_file.csv");
header("Pragma: no-cache");
header("Expires: 0");
$data = array(
array('aaa', 'bbb', 'ccc', 'dddd'),
array('123', '456', '789'),
array('aaa', 'bbb')
);
$output = fopen("php://output", "w");
foreach ($data as $row) {
fputcsv($output, $row);
}
fclose($output);
I wonder what is wrong?
My header:
CodePudding user response: