Code: Select all
header("Content-type: application/msword");
header('Content-Disposition: attachment; filename='.$fileName);
echo $content;
die;I narrowed down the issue (hours going by) to occurring after the headers are sent. Same happens when the file is read directly from the original file, so it is not a mysql issue. $content has the correct strlen (with mb_strlen) but the downloaded file has increased by 3 bytes. Other headers (transfer encoding, content-length) make no difference nor specifying ansi as charset. I am using LAMP.
This issue turns up a lot at forums but there it is the famous headers already sent problem which for individual files can be resolved easily with a hex editor. I need to avoid the issue occurring in the first place.