When creating and downloading a CSV from a database call using: putcsv, header and php outstream (php://output).

// Output headers
header("Content-Type: text/csv; charset=utf8");
header("Content-Disposition: attachment; filename=" . $_REQUEST['filename']);

// Create a file pointer to the output stream
$output = fopen('php://output', 'w');

// Output the column headings
fputcsv($output, $columnNames);

// For each data row add new row to csv file
foreach($data as $dta)
    fputcsv($output, $dta);

When the a user downloads the csv a minute later their chrome completely crashes and shuts down. The CSV downloaded is only 676KB.

Thanks in advance for any help.

There is some aditional info: Chrome has a separate process for each tab so that if one goes down it doesn't take the whole browser down but in this case it causes the whole browser to freeze and windows says "Google Chrome as crashed" with end process button

Hi, thanks for your reply. I'm not 100% sure it's not my chrome that has the issues it's my colleagues, I've asked them to try your test with 5000 line and I'll post with the results of the test if and where I get to with this issue.

My colleague tried your CSV download script with 5000 rows and caused no issues =/. Not quite sure where to go next

Try to check the headers and the logs created by your server (both access and error logs) to see if it happens something wrong. Also could you show a sample of the data that will return your CSV?