0

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.

3
Contributors
6
Replies
33
Views
3 Years
Discussion Span
Last Post by ziaurehman
0

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

0

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.

0

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

0

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?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.