Try passing the file through preg_replace.  Replace all \n with \r\n.  

-- 
Scott Carr
OpenOffice.org
Whiteboard-Doc Maintainer
http://whiteboard.openoffice.org/doc/


Quoting Henry Grech-Cini <[EMAIL PROTECTED]>:

> Dear All,
> 
> Firstly, I am a newbie to php so please be gentle.
> 
> I'm having problems with carriage returns placed in a file on a Linux based
> server. When this file is download to a WindowsXP machine the carriage
> returns are quite frankly useless. I just get "[]" (where "[]" represents
> an
> undisplayable character. No actual carriage returns or newlines!
> 
> I generate the file using the following code (fragment only):
> 
>  while($row=mysql_fetch_array($mysql_result))
>     {
>       $f_title=$row["title"];
>       $f_first_name=$row["first_name"];
>       $f_surname=$row["surname"];
>       $f_email=$row["email"];
>       fputs($file_op,"$f_title, $f_first_name, $f_surname, $f_email\n");
>     }
> 
> I then use the following link to a download_it.php script as described in
> Tansley as follows:
> 
> $parameters="file_name=".urlencode($file_name)."&file_size=$file_size";
>  echo "<A HREF=\"downloadit.php?$parameters\">download it</A>";
> 
> The download_it.php file looks as follows:
> <?php
> #downloadit.php
> $file_name=urldecode($file_name);
> header("Content-type: Application/octet-stream");
> header("Content-Disposition: attachment;filename=download/download.txt");
> header("Content-Description: PHP Download");
> header("Content-Length: $file_size");
> readfile($file_name);
> ?>
> 
> Appart from the fact that the Content-Disposition appears not to be working
> under IE6 since the file name is not correct.
> 
> The downloaded file does not contain Windows type carriage returns of
> newlines! However it does contains the data thank goodness.
> 
> What is the fix?
> 
> Henry Grech-Cini
> 
> 
> 
> -- 
> PHP Windows Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 


-------------------------------------------------
This mail sent through IMP: http://horde.org/imp/

-- 
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to