PDA

View Full Version : PHP Header for ASCII Downloads


tribby
05-06-2001, 03:35 PM
Hi,

I wrote a small PHP script for downloading text files from my site.

To accomplish this, I've used the following headers:

header( "Content-type: text/plain" );
header( "Content-Disposition: attachment; filename=$filename" );
header( "Content-Description: PHP Generated Data" );

Setting the Content-Disposition to 'attachment' forces a download, which is what I want. However, this apprently forces the file to download as a binary file... Since it's downloading a text file I need it to transfer as an ascii file instead... Otherwise, instead of the file having line breaks, the whole file is on one line with a single character representing each line break. Anyone know a work-around or another way to accomplish this?

Thanks,
Tribby

jhillman
05-07-2001, 11:59 AM
I'm not sure how you would download a TXT file, but you can solve the one-line continuation by setting your favorite text editor to enable word wrap once you have the file downloaded.

-Joe

Enrico
05-11-2001, 09:13 AM
<?
header("Content-disposition: filename=ascii.txt");
header("Content-type: application/octetstream");
header("Pragma: no-cache");
header("Expires: 0");
print "this file is a ascii file:)";




?>

tribby
05-11-2001, 04:08 PM
Nope, still downloaded it as a binary file. Thanks though :)