snakeriver
asked on
Header download of word doc is jumbled
Hello,
I'm trying to send a file to a browser. The file type is a word doc. When the word doc downloads, and I try to open it, the text is all jumbled. This code works fine for pdf's and images by changing the Content-Type accordingly...
I'm trying to send a file to a browser. The file type is a word doc. When the word doc downloads, and I try to open it, the text is all jumbled. This code works fine for pdf's and images by changing the Content-Type accordingly...
if(!is_file($fullpath)) {
exit('File not found');
}
header('Cache-control: private');
header('Pragma: public');
header('Content-Type: application/msword');
header('Content-Length: ' . filesize($fullpath));
header("Content-Transfer-Encoding: binary");
header('Content-Disposition: attachment; filename="' . urldecode($path) . '"');
flush();
$file = fopen($fullpath, 'r');
while (!feof($file))
{
print fread($file, filesize($fullpath));
flush();
}
fclose($file);
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
<?php
code here...
?>
<?php
code here...
?>
I got rid of the space between the two, and it works just fine. I guess it was just putting an extra line break before the header output...