<?php
ob_start();
$file = 'pdf/tubebrochure.pdf'; // file to be downloaded
header("Expires:0");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache"); header("Content-type: application/pdf");
header('Content-length: '.filesize($file));
header('Content-disposition: attachment; filename='.basename($file));
readfile($file);
exit;
ob_end_flush();
?>
ขึ้น error ว่า
Warning: Cannot modify header information - headers already sent by (output started at /home/xxxxx/domains/domain.com/public_html/cp4.php:4) in /home/xxxxx/domains/domain.com/public_html/cp4.php on line 7
error line 7 - line 13 คือส่วนของ
Code (PHP)
header("Expires:0");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache"); header("Content-type: application/pdf");
header('Content-length: '.filesize($file));
header('Content-disposition: attachment; filename='.basename($file));
readfile($file);