I can't see what is wrong with the code below. Strangely, what happens, is that the file on the server saves fine, and correctly - i.e. the "this is text....file" is written to the file no problem, but, when it enters the code for the download to user, it trys to download into the file the html code from the page it's just come from!!!!!!!!
I don't understand why!
Can anyone see what is wrong?.....
<?
$buffertemp = "this is text for the file";
//DOWNLOAD TO USER
if ($action == "save") {
$FilenameForDownload = "baboon.txt";
$fpc = fopen($FilenameForDownload,'w');
fwrite($fpc,$buffertemp);
fclose($fpc);
$download_size = filesize($FilenameForDownload);
header("Content-Type: application/text");
header("Content-Disposition: attachment; filename=$FilenameForDownload;");
header("Accept-Ranges: bytes");
header("Content-Length: $download_size");
@readfile($FilenameForDownload);
}
?>