Create and Dispose dynamic content

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

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:
Quoted text here. Click to load it

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.


In A.html

<A href="B.php">Download</A>

In B.php


header('Content-type: text/plain');
header('Content-Disposition: attachment; filename="stuff.txt"');

echo "Whatever dynamically generated stuff you want!!";



Re: Create and Dispose dynamic content

cool, I'll give it a try

Site Timeline