Reply to Downloaded word document not correct

Your name:

Reply:


Posted by Taras_96 on 03/10/07 07:21

Hi everyone,

I'm using PHP and a DB to control access to files that have been
uploaded by users. I am using the following PHP code snippet to
deliver the file after the access rights have been checked.

$theFile = file_get_contents(UPLOAD_PATH.$storedName);
if($mimeExtension == '')
{
header("Content-Type: application/octet-stream\n");
}
else
{
header("Content-Type: $mimeExtension\n");
}
header("Content-Disposition: attachment; filename=
\"$documentName\"\n");
// doesn't work with base64 or binary
header("Content-Transfer-Encoding: binary\n");
header("Content-length: " . strlen($theFile) . "\n");

echo $theFile;

Now, text files open up fine. Word documents though, especially those
with embedded photos, come out mangled. I have tried sending the word
document with the content type being sent to both application/octet-
stream and the word document one. The file on the server (which is my
computer, as I am currently developing the site) is fine. This means
that something goes wrong while the file is being sent. I suspect the
Content-Transfer-Encoding header, but setting it to binary (which was
my original code) or base64 doesn't fix the problem. What could
possible be the problem?

Secondly, when the user presses 'save', the save button remains
depressed until the document has finished uploading. It's as if the
save operation 'blocks', rather than adding the save to the download
manager and getting rid of the save screen. That is, the 'save as'
screen remains visible, with the save button pressed down, until the
file is completely downloaded. How can I avoid this?

Cheers

Taras

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация