timdiacon Posted March 8, 2006 Share Posted March 8, 2006 Hello,I am using fpdf to create PDF's store them on my server and then allow people to download them. However I would like to add a line in my pdf generation script which searches the directory where they are stored and removes any PDF's that are more than a week old.Any help on how to do this would be much appreciated.Thanks. Quote Link to comment Share on other sites More sharing options...
AV1611 Posted March 8, 2006 Share Posted March 8, 2006 Wow, I'd like to know the answer to that as well!That being said, could you trying incorporating the date into the file name?Or, perhaps you could track PDF creation with a table? Then you could use the table to tell you which one to delete? Quote Link to comment Share on other sites More sharing options...
timdiacon Posted March 8, 2006 Author Share Posted March 8, 2006 actually I think I have found the answer on php.net...[code] if (is_dir("$path") ) { $handle=opendir($path); while (false!==($file = readdir($handle))) { if ($file != "." && $file != "..") { $Diff = (time() - filectime("$path/$file"))/60/60/24; if ($Diff > 14) unlink("$path/$file"); } } closedir($handle); }[/code] Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.