kkreft
2/27/2014 - 1:57 PM

PHP force download

$url = 'zgloszenia.xlsx';
error_reporting( 0 );
header('Content-Description: File Transfer');
header('Cache-Control: public, must-revalidate, max-age=0'); // HTTP/1.1
header('Pragma: public');
header('Expires: Sat, 26 Jul 1997 05:00:00 GMT'); // Date in the past
header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
 
header('Content-Type: application/force-download');
header('Content-Type: application/octet-stream', false);
header('Content-Type: application/download', false);
 
header('Content-Disposition: attachment; filename="'.$url.'";');
header('Content-Transfer-Encoding: binary');
header('Content-Length: '.filesize($url));
ob_clean();
flush();
readfile($url);
$objWriter->save('php://output');
exit;