ID: 42661 Comment by: alex94040 at yahoo dot com Reported By: christian at vaneeden dot ca Status: No Feedback Bug Type: Streams related Operating System: Redhat AS 4 PHP Version: 5.2.4 New Comment:
I'm experiencing the same issue on PHP 5.2.9 on Apache + Windows 7. readfile() as a workaround doesn't work for me - same garbled text. Previous Comments: ------------------------------------------------------------------------ [2007-09-27 01:00:01] php-bugs at lists dot php dot net No feedback was provided for this bug for over a week, so it is being suspended automatically. If you are able to provide the information that was originally requested, please do so and change the status of the bug back to "Open". ------------------------------------------------------------------------ [2007-09-19 10:30:57] [email protected] Just a note: using file_get_contents() in this is not very useful, readfile() is much better anyway. Try this little script to see that it's is actually file_get_contents() that is buggy: <?php error_reporting(E_ALL); ini_set('display_errors', 1); $docFile = file_get_contents( 'word.doc' ); echo strlen($docFile), "\n"; echo file_put_contents( 'copy_word.doc', $docFile ), "\n"; ?> Then run this on the result: # diff -a word.doc copy_word.doc They should not differ.. ------------------------------------------------------------------------ [2007-09-13 16:15:05] christian at vaneeden dot ca Description: ------------ When you read in a binary file with file_get_contents() and try to output it, it comes out garbled. Note: as a workaround use readfile() Reproduce code: --------------- $docFile = file_get_contents( 'word.doc' ); header('Content-type: application/msword; charset: UTF-8'); header('Content-Disposition: attachment; filename="word.doc'"'); header('Cache-Control: must-revalidate'); print $docFile; Expected result: ---------------- A proper word document. Actual result: -------------- Garbled binary text. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=42661&edit=1
