Re: Line Breaks in dynamic Download
| From: | Kevin Stone | Date: | Fri, 06 Sep 2002 21:42:20 +0000 |
| Subject: | Re: Line Breaks in dynamic Download | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-115574@lists.php.net to get a copy of this message | ||
Thank you all very much. Turns out it was yet another browser cache issue
and a quick reboot solved the problem. Minor modification of just two lines
and I'm back in business. It's the details that'll kill you, eh? :)
Final code...
<?
header("Cache-control: private");
header("Content-Type: application/octet-stream");
header("Content-Disposition: attachment; filename=emaillist.txt");
$query = "SELECT $field_str FROM helpelf_email_lists WHERE clientid='$view'
ORDER BY timestamp DESC";
$result = mysql_query($query, $db);
while ($row = mysql_fetch_row($result))
{
$file_array = array();
for ($i=0; $i<count($row); $i++)
{
// Replace any commas with periods.
$row[$i] = str_replace(',', '.', $row[$i]);
$tmp_row = addslashes($row[$i]);
$file_array[] = $enclosed.$tmp_row.$enclosed;
}
$file_tmp = implode($separator, $file_array);
echo $file_tmp.chr(13).chr(10);
}
?>
Again much thanks to everyone who helped me.
--
Kevin Stone
kevin@helpelf.com
----- Original Message -----
From: "Steven" <lists@ellermann.com>
To: <php-general@lists.php.net>
Sent: Friday, September 06, 2002 1:50 PM
Subject: [PHP] Line Breaks in dynamic Download
> <snip>
> Again, the new problem is that the Text is not downloading as a file. It
is
> just being printed to the screen.
> </snip>
>
> I tested the following code:
>
> <?
> header("Content-type: application/octet-stream");
> header("Content-Disposition: attachment; filename=TEST.txt");
> echo "LINE ONE".chr(10)."LINE TWO".chr(10)."LINE THREE";
> ?>
>
> on a WinNT 4.0 with Apache 1.3.24 and PHP 4.2.3 and did not come across
the
> same issues as you.
>
> I was prompted to download or open the file.
>
> However, when I did open the file with Notepad it did not contain any line
> breaks, Wordpad did have the line breaks.
>
> HTH
> Steven
>
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>