Yngve wrote:

I wonder if it´s possible (and how) to delete a file after it has been
downloaded, without running anything on the server except for the PHP page
which the user gets the file from.

unlink()

You need a middle man script to manage the download and delete the file. The script receives the request, send the appropriate file headers, uses readfile() to send the file data, then deletes the file with unlink().

If it is not possible, i wonder how i could create a script which deletes
all files in a directory which are more than 5 hours old?

opendir() and readdir() to loop through the file and filectime()/filemtime()/fileatime() to get the age of the file (depending on how you define 5 hours old).


You could also just make a system() call to the command line to delete the files or just have something run by cron.

--

---John Holmes...

Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

php|architect: The Magazine for PHP Professionals – www.phparch.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to