Different size of file on server and on output

From: Date: Mon, 22 Oct 2007 11:57:08 +0000
Subject: Different size of file on server and on output
Groups: php.general 
Request: Send a blank email to php-general+get-263489@lists.php.net to get a copy of this message
Hello to everybody, I have this problem with downloading files via PHP. For illustration - I am using this fragment of code: <?php header("Content-type: $contenttype; name=\"$outputfilename\""); header("Content-disposition: form-data; filename=\"$outputfilename\"");
    $fp=fopen($filename,'r');
while (!FEof($fp)): $filedata.=fread($fp,8192); endwhile; fclose($fp); echo $filedata; ?> The problem is, that the file on server has 16857 bytes and saved file has 16858. In another case downloaded file has everytime 1 byte more than the original file on server. When I put JPEG or ZIP forexample to output, there is no problem with opening file like this. Bud when I am trying .docx (Office2007 file format) it occures mistake during opening this file in MSOffice... Can anybody helps me with this problem? Why is the file size increasing one byte? Whitch byte it is? Thanks a lot! Pavel

« previous php.general (#263489) next »