Downloading file removes CR LF

Links for php scripts

Moderators: macek, egami, gesf

New php-forum User
New php-forum User
Posts: 1
Joined: Sat Jul 28, 2012 8:07 am

Downloading file removes CR LF

Postby john57 » Sat Jul 28, 2012 8:24 am

Hi, I'm new to PHP and found the following code for downloading a file from website.

header("Content-Description: File Transfer");
header("Content-Disposition: attachment; filename=$tofile");
header("Content-Type: application/octet-stream");
header("Content-Transfer-Encoding: binary");
header('Pragma: no-cache');
header('Expires: 0');

It works fine except that all CR LF are removed and the text appears just as one large block (after being downloaded). The file is a simple text file '.txt'. Tried it on a simple text file created in notepad and this has the same effect. THe file on the server is fine as have downloaded it via FTP and appears as it should. Tried a few variations using type of 'text' etc. but still same issue. Same effect in IE and Chrome. Help gratefully received. Thanks J

Return to “PHP Scripts”

Who is online

Users browsing this forum: No registered users and 1 guest