Board index   FAQ   Search  
Register  Login
Board index PHP PHP Scripts

Downloading file removes CR LF

Links for php scripts

Moderators: macek, egami, gesf

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');
readfile($frfile);

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
john57
New php-forum User
New php-forum User
 
Posts: 1
Joined: Sat Jul 28, 2012 8:07 am

Return to PHP Scripts

Who is online

Users browsing this forum: Google Feedfetcher and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.