I need to generate a text file inline from my code. I know how to generate a downloadable file using an external php script, like this...
But I have a very intensive script that does a lot of processing and takes a long time. So what I'd like is to avoid having to do it twice. Anyone know how to do something like this?
<? //Generate text file on the fly - text.php
header("Content-Disposition: attachment; filename=savethis.txt");
// do your Db stuff here to get the content into $content
print "This is some text...\n";
<a href="text.php">Download me</a>
this would basically be generating a file in memory without having to write a temp file, but do it without having to call an external php script.
// contact the DB and get lots of info and parse it into $content
Read it here<br>
or download it";
//generate the downloadable version here somehow => $contentfile
print "<a href="$contentfile">Here!</a></body></html>";
Anyone tried something like this before? Help...