0

I am having a problem to open a csv file.

I have a export button. On click, a csv file is generated with data from my database.

The generated file is opening correctly at my place but the same file is breaking on my client pc.

Can someone help me out with this.

Thanks

1 Answer 1

1

Form csv properly as follows,

$arr = ("data1,data2,data3,data3","data1,data2,data3,data3","data1,data2,data3,data3"); $fp = fopen('/tmp/reports.csv', 'w'); foreach ($arrData as $line) { fputcsv($fp, explode(',', $line)); } fclose($fp); header('Content-type: application/excel'); header('Content-Disposition: attachment; filename="reports.csv"'); readfile('/tmp/reports.csv'); 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.