[eluser]Sudz[/eluser]
[quote author="Sudhakar Prajapati" date="1304168206"]I got this output : Headers were already sent at : on line : 0[/quote]
Here is my code
Code:
ob_start();
$objWriter->save('php://output');
$file_name = ob_get_contents();
ob_end_clean();
zipFilesAndDownload($file_name,'./user_data/leads.zip');
function zipFilesAndDownload($file_name,$archive_file_name)
{
//create the object
$zip = new ZipArchive();
//create the file and throw the error if unsuccessful
if ($zip->open($archive_file_name, ZIPARCHIVE::CREATE )!==TRUE) {
exit("cannot open <$archive_file_name>\n");
}
//add each files of $file_name array to archive
$zip->addFromString("leads/export.xls",$file_name);
$zip->close();
//then send the headers to force download the zip file
header('Content-Type: application/vnd.ms-excel');
header("Content-Disposition: attachment;filename=$archive_file_name");
header('Cache-Control: max-age=0');
header("Content-Transfer-Encoding: binary");
header('Pragma: public');
readfile($archive_file_name);
exit;
}
What i am missing?