By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,405 Members | 1,691 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,405 IT Pros & Developers. It's quick & easy.

Create and Dispose dynamic content

P: n/a
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.

Thanks,

Jul 17 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Dale said the following on 05/06/2005 15:03:
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.


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.

e.g.

In A.html
=========

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

<?php

header('Content-type: text/plain');
header('Content-Disposition: attachment; filename="stuff.txt"');
echo "Whatever dynamically generated stuff you want!!";
....

?>

--
Oli
Jul 17 '05 #2

P: n/a
cool, I'll give it a try

Jul 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.