Forum Moderators: coopster

Message Too Old, No Replies

Copying my HTML/PHP text to a file for download

PHP download text document

         

Richard_A

9:12 pm on Aug 10, 2007 (gmt 0)

10+ Year Member



Hey guys. I'm still relatively new using PHP. I was working on a project ("sure Boss... I know PHP") and have hit a wall.

I've lined up some questions throughout several PHP-scripted pages which result in a "built" contract (depending on how they answered the questions-which paragraphs were included in the contract). Now, I'm trying to find a way to take the finalized contract (titled "final_[system]_[phase].php") and copy the contents to a downloadable (whether .doc or .txt) file so that customers can have their own copy.

I thought about writing some MASSIVE loop statements to determine a static file for each, individual contract,(each final document can have 10 - 12 different additions) but it would be easier if I could find a way to select ALL the text from the "final_[system]_[phase].php"-page and make that their downloadable file. Any suggestions? I really appreciate ANY help. Thanks,
Richard_A

[edited by: Richard_A at 9:14 pm (utc) on Aug. 10, 2007]

WesleyC

9:28 pm on Aug 10, 2007 (gmt 0)

10+ Year Member



Inside final_[system]_[phase].php add this line before any output:

header("Content-disposition: attachment; filename=filename.txt");

Then, whenever the page is accessed, the user will be prompted to save the file to their computer.

Richard_A

9:37 pm on Aug 10, 2007 (gmt 0)

10+ Year Member



That's cool... but I'd really like them to see the finished contract before they download it, and it still has all the <html> tags in it.

Thank you for the response, and I hate being picky.. but it's not quite what I was looking for... any other suggestions?