note 46454 deleted from function.header by tularis

From: Date: Tue, 12 Oct 2004 11:22:42 +0000
Subject: note 46454 deleted from function.header by tularis
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-78400@lists.php.net to get a copy of this message
Note Submitter: obren at mail dot com ---- May save some time and nerves to somebody... I have the following fragment of code in my PHP script: ... header('Cache-Control: no-cache, must-revalidate'); header('Content-Description: File Transfer'); header('Content-Type: application/octet-stream'); header('Content-Length: '.filesize($fname)); header('Content-Disposition: attachment; filename='.basename($fname)); $f = fopen($fname, 'rb'); fpassthru($f); fclose($f); ... But, this produces corrupted binary files on receiving side. After hours of headbanging, I found that the reson are whitespaces around one <?php ... ?> fragment! <form ... action="<?=$_SERVER["PHP_SELF"]?>"> <?php ... Notice that "whitespace" between <form> tag and <?php> tag! Strange, but once I removed the space, the problem with corrupted files dissapeared. Looks like space character somehow remained in the output buffer and got transfered as the content of binary file. Regards, Dragan

« previous php.notes (#78400) next »