Write a file from a form, download the file, and then delete
Posted: Fri Apr 22, 2005 10:03 am
I'm using three pieces of code that I found online. The first and last parts are from a tutorial on how to write a file to the server and how to delete a file.
And then I'm using another piece for the user to download the file.
Basically, it's a form that will be used a lot to dynamically create html files. But since I don't want a thousand files left on my server, I'm creating the file, then deleting it when they're done.
So far, everything works fine. The last step is to have the user re-directed back to the form after they've downloaded the page.
Problem though is timing, I think I've got three files... the form (html), the first php page that writes the file and links to the php file that downloads (and then deletes) the file. By "download", I mean, pops up the window for them to save the file.
The file I'm using for the download is called "force-download.php" - found it here:
http://www.elouai.com/force-download.php
It's all just a txt file, am I over-complicating things?
And then I'm using another piece for the user to download the file.
Basically, it's a form that will be used a lot to dynamically create html files. But since I don't want a thousand files left on my server, I'm creating the file, then deleting it when they're done.
So far, everything works fine. The last step is to have the user re-directed back to the form after they've downloaded the page.
Problem though is timing, I think I've got three files... the form (html), the first php page that writes the file and links to the php file that downloads (and then deletes) the file. By "download", I mean, pops up the window for them to save the file.
The file I'm using for the download is called "force-download.php" - found it here:
http://www.elouai.com/force-download.php
It's all just a txt file, am I over-complicating things?