I know there are a lot of Q&As on http headers but I can't seem to find an answer to this one:
I have a link which downloads a file. I can download plain ASCII files no problem, but I cannot seem to download other files such as .doc, .zip, etc.
This works for text files:
$file="c:\source\myfiles\myfile.txt";
Header("Content-type: application/download");
Header ( "Content-Length: ".filesize($file));
Header( "Content-Disposition: attachment; filename=myfile.txt");
readfile($file);
But this doesn't work for a word doc:
$file="c:\source\myfiles\myfile.doc";
Header("Content-Type: application/msword");
Header ( "Content-Length: ".filesize($file));
Header( "Content-Disposition: attachment; filename=myfile.doc");
readfile($file);
It downloads an empty file (well, almost empty 46bytes but when I open it it's empty)
Any help on this would be greatly appreciated!
--Matt