Text Downloadable Files with PHP
Posted on Jun 28, 2013
I needed to create a file which had to be downloaded.
The file had to be in plain text and contents from file come from database. Because I didn't had
a separate folder for each user I couldn't write the information to a file to the server and put a link
in order the user to download it. I even try to other formats like .xls, .doc, .csv and it works really nice.
Code for downloadable file:
Code for downloadable file:
<? header("Content-type: application/octet-stream"); header("Content-Disposition: attachment; filename=\"your_file.txt\""); echo 'Text for downloadable file'; ?>