Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
- Create and Dispose dynamic content
June 5, 2005, 12:03 pm
rate this thread
I am trying to figure out how to have a script dynamically create and
then dispose of a text file. A script will generate a text file using
the standard I/O functions and then present a link so the user can
right-click and download. That part is easy. The file could be
created in a unique directory on the server for each user such that
different users don't clobber each other. How can I make sure the file
is later removed if the user backs out of the page and doesn't
explicitly logoff. I suppose it boils down to is there a way to write
a script that gets executed when a session ends whether the user
explicitly logged out or not.
Re: Create and Dispose dynamic content
Dale said the following on 05/06/2005 15:03:
An easier way would be have the link go to another PHP script, which
generates the text content, and then serves it as an attachment, so no
need to save anything to disk.
header('Content-Disposition: attachment; filename="stuff.txt"');
echo "Whatever dynamically generated stuff you want!!";