Sunday 2 September 2018

xml - Warning: Cannot modify header information - headers already sent by (output started at /Applications/MAMP/htdocs/indesign/index1.php:7)








I am using MAMP and working with the xml file. I want to give a download option to download a file with option using this code:



$savefile="hello.xml";
header("Pragma: public"); // required
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: private", false); // required for certain browsers
header("Content-Type: application/octet-stream");
header("Content-Disposition: attachment; filename=\"" . $savefile . "\";");

header("Content-Transfer-Encoding: binary");
// header("Content-Length: " . filesize($parsed_url['localpath']));
readfile($$savefile);


It gives me this error when i run it:




Warning: Cannot modify header information - headers already sent by (output started at /Applications/MAMP/htdocs/check/index1.php:7) in /Applications/MAMP/htdocs/check/index1.php on line 51


No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...