Content-length header ignored
Posted: Mon Feb 14, 2011 12:37 pm
I am using the following code to create and download a file. It used to work, but now the 377kb file end up as an 800kb file whe downloaded, with the page html included at the end. Any ideas as to why this wouln't work all of a suden?
Code: Select all
$fp = fopen("exported-recipes.mmf", "a");
fwrite( $fp, $mmf_output);
fclose($fp);
$size_file=filesize("exported-recipes.mmf");
header('Content-type: text/mmf');
// It will be called exported-recipes.mmf
header('Content-Disposition: attachment; filename="exported-recipes.mmf"');
//only output the contents of the file
header("Content-Description: Download PHP");
header("Content-Length: $size_file");
// The CSV source is in exported-recipes.csv
readfile('exported-recipes.mmf');