I have an issue, my application works as follows.
First echo to the user that the generating of the csv file has started.
eg. echo 'Building of csv file started';
then I build the csv file.
Now I want to force the file to download, and this works perfectly.
this is my code
header('Content-Type: application/csv');
header('Content-Disposition:attachment;filename='.$year.'_'.$month.'_'.'export.csv');
header('Pragma: no-cache');
echo readfile($myFile);
No the first echo ‘Building of csv file started’ gets included in the CSV file and I do not know how to exlude it.
The solution is really easy.
As you want two different header types you have to create 2 different pages.
The first page displaying “Building of csv file started” and containing an iframe with your second page and a second page with your real csv file and the attachment header.