Re: Download adds ^M to beginning of file
| From: | Richard Lynch | Date: | Sat, 16 Dec 2006 05:25:40 +0000 |
| Subject: | Re: Download adds ^M to beginning of file | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-245903@lists.php.net to get a copy of this message | ||
On Tue, December 12, 2006 9:12 am, lists@dwsasia.com wrote:
Based on your subject line, I'd suggest looking for an included PHP
script that has a stray newline (a Windows newline, actually) before
the <?php or after the ?>
> 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......
If you are using Perl, why are you posting it here?...
> 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");
I know I've posted this twice today, but here we are again:
http://richardlynch.blogspot.com/
> $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.
Why do you have the ob_end_flush() in there anyway?
Is this code on your server that you control?
Then you shouldn't have any ob_start() calls in your way in the first
place. :-)
--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?