<?php
header("Content-Type: text/csv");
header("Cache-Control: no-store, no-cache");
header('Content-Disposition: attachment; Filename="Selected_Resumes.csv"');
$outstream = fopen("php://output",'w'); //Directly ask for download with out saving
//$outstream = fopen('bath/list.csv', 'w'); // Save file on sever then ask for download
fputcsv($outstream, $titles);
foreach ($result as $data) {
fputcsv($outstream, $data);
}
fclose($outstream);
//unlink('bath/list.csv'); // Use this to delete file, if you are using save file on server.
?>
Note: Better we can directly ask for download output as CSV, with out saving them in server.
header("Content-Type: text/csv");
header("Cache-Control: no-store, no-cache");
header('Content-Disposition: attachment; Filename="Selected_Resumes.csv"');
$outstream = fopen("php://output",'w'); //Directly ask for download with out saving
//$outstream = fopen('bath/list.csv', 'w'); // Save file on sever then ask for download
fputcsv($outstream, $titles);
foreach ($result as $data) {
fputcsv($outstream, $data);
}
fclose($outstream);
//unlink('bath/list.csv'); // Use this to delete file, if you are using save file on server.
?>
Note: Better we can directly ask for download output as CSV, with out saving them in server.
No comments:
Post a Comment