PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
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?
$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');
barb woolums wrote:Any ideas as to why this wouln't work all of a suden?
Basically, because that's what you told it to do
An exit(); after the readfile() will stop the execution at that point and will not append the extra data to the file.