Download adds ^M to beginning of file

From: Date: Tue, 12 Dec 2006 15:12:01 +0000
Subject: Download adds ^M to beginning of file
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-245755@lists.php.net to get a copy of this message
Hi, Using the below code to force download works fine on most servers and with most browsers. However it does "crash" Firefox when I download a specific file, IE works like beauty. File content starts with: #!/sbin/_joor_perl_use Filter::decrypt...... This is the code to force the download: header("Pragma: public"); header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Content-Type: application/octet-stream"); header("Content-Disposition: attachment; filename=\"$file\""); header("Content-Transfer-Encoding: binary"); header("Content-Length: $size"); $file = fopen($completePath, 'r'); while(ob_get_level()) { ob_end_flush(); } while(!feof($file)) { echo fread($file, 2048); } fclose($file); Where can I start? Could it be server config? Or could it have to do with flush? If I remove the ob_end_flush() it does not crash Firefox. Best regards, Peter Lauri

« previous php.general (#245755) next »