I am trying to write to and then download a file. I am not having any trouble opening, writing to, or closing the file. I can ftp it off the server, and everything is how it should be. But when I try to download it, I get the php file that I am trying to download from. All the code does now is write a test message to the file and try to download. Here it is:
function download($type){
$filename= "/home/ermc2/ermc2-Www/downloaded.txt";
$fp = fopen($filename, "w") or die("Can't open file.");
$fout = fwrite($fp, "Testing file download");
fclose($fp);
Header("Content-Type: text/plain");
Header("Content-Length: " . filesize($filename));
Header("Content-Disposition: attachment; $filename");
}
I have tried a million different things, and I am sure the answer is obvious - but not to me!
Thanks