Start New Discussion Reply to this Discussion exporting/downloading txt file - readfile(); problems - creating line break
Greetings,
I created a script to export member's items into a tab-delimited txt file. The script works great, it escapes tabs and new lines and creates a perfect export.txt file.
Problem: I have another link so people can download the export.txt file onto their computers using:
PHP Code:
$file = "export-files/".$member.".txt";
header('Content-Description: File Transfer');
header('Content-Type: text/plain');
header('Content-Disposition: attachment; filename='.basename($file));
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize($file));
ob_clean();
flush();
readfile($file);
exit();
When I download export.txt, it appears to have newly created line-breaks that are not found in the export.txt file on the server. Does anyone know why this happens and how to prevent this?
Thanks
17 Minutes
Discussion Span
wickland
Newbie Poster
2 posts since Dec 2012
Reputation Points: 0
Solved Threads: 0
Skill Endorsements: 0
Nevermind, I added "\r\n" instead of "\n" to the exported txt file and it recognizes the line breaks. Took 8 hours to figure it out.
I may have to come back later to figure out why file is not re-importing...
Thanks for looking.
HHHHHHHHHHHHHMMMMMMMMMMMMMMMMMMM. YUP, it was two characters and a single TAB that eluded me for hours and hours until 2 minutes after writing on the forum.
wickland
Newbie Poster
2 posts since Dec 2012
Reputation Points: 0
Solved Threads: 0
Skill Endorsements: 0
© 2013 DaniWeb® LLC
Page rendered in 0.3014 seconds
using 2.66MB