On Wed, 18 Aug 2004 23:56:57 +0200, Yngve <[EMAIL PROTECTED]> wrote: > Hi! > > 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. > > 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?
http://us3.php.net/unlink or something like this define(FILE_DIRECTORY , path to your directory); define(DELETE_TIME , 18000); //5 hours $current_time = time(); // Open a known directory, and proceed to read its contents if (is_dir(FILE_DIRECTORY)) { if ($dh = opendir(FILE_DIRECTORY)) { while (($file = readdir($dh)) !== false) { if (is_file(FILE_DIRECTORY.$file) ) { $file_time = filectime ( FILE_DIRECTORY.$file ); if ($current_time - $file_time > DELETE_TIME ) { unlink(FILE_DIRECTORY.$file); } } } closedir($dh); } } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php