I am trying to download a word document on the server through PHP. I'm using the foll. code . But the downloaded file outputs some garbage data.
Can anyone please help me?
Thx. in advance
$saveasname = basename($filename);
$fileContents = file_get_contents($filename);
if (preg_match('/MSIE 5.5/', $browser)
|| preg_match('/MSIE 6.0/', $browser))
{
header('Content-Disposition: filename="'.$saveasname.'"');
}
else
{
header('Content-Disposition: attachment; filename="'.$saveasname.'"');
}
//header("Content-Disposition: attachment; filename=".$fileName);
header("Content-Transfer-Encoding: binary");
header("Content-Type: application/octet-stream; name=".$filename);
echo($fileContents);
exit;
File downloading problem
Moderator: General Moderators