yungbloodreborn Posted June 25, 2008 Share Posted June 25, 2008 I would like to generate a file, and give it a name for a download. The result would be something like: <a href="http://mysite.com/getfile.php?file=1335">Download Poem</a> When I click that link, I want it to pop up a save as (download) box. I want the name that appears in that box to be whatever I choose. (i.e. 'odephp.txt') And the contents of the file would be generated from a script. <?php echo 'Ode to PHP'; echo '................'; echo 'Php how do I love thee?'; echo 'Let me count the ways'; $max = $_REQUEST['file']; $cnt = 0; while ($cnt < $max) { echo "$cnt..."; $cnt++; } ?> I would imagine that I need some kind of header call, but I'm missing a key piece to make it all work. Can someone please help? Link to comment https://forums.phpfreaks.com/topic/111931-solved-download-generated-file/ Share on other sites More sharing options...
yungbloodreborn Posted June 25, 2008 Author Share Posted June 25, 2008 Damn, I just found the answer in another post. heh The answer wasn't there when I posted the first time... <?php header('Content-Disposition: attachment; filename="odephp.txt"'); printf("Ode to php\n"); printf("...\n"); ?> Link to comment https://forums.phpfreaks.com/topic/111931-solved-download-generated-file/#findComment-574497 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.