PHP: Correct File Delivery Headers for Internet Explorer 2011-06-15

Internet explorer is somewhat silly when it comes to download a file from a non-file URL (like a script, e.g. index.php?file=myfile.txt). This little PHP code on the server-side solved all my IE problems:

header("Content-Type: application/octet-stream");
header("Content-Disposition: attachment; filename=\"".$orig_filename."\"");
header("Pragma: no-cache"); // IMPORTANT FOR IE
header("Cache-Control: no-cache"); // IMPORTANT FOR IE
$fd = fopen ($fullPathToDonwloadFile, "r");
while(!feof($fd)) {
    $buffer = fread($fd, 2048);
    echo $buffer;
}