jasonc Posted August 12, 2009 Share Posted August 12, 2009 I am wanting to delete temporary files from a folder that have a file name value of todays date minus one hour and all files created before this time. i have the following but this only works for files created on the day this script is run, if i get no members for a day or two then files created will remain in folder and each time this happens more and more are kept. what is the best way to code the below to get this to work <? foreach (glob("temp_files/" . gmdate("Y-m-d_") . "*.png") as $filename) { unlink($filename) or die($errorcode = mysql_error()); if (isset($errorcode)) { echo("error in delete"); } } ?> Link to comment https://forums.phpfreaks.com/topic/169856-delete-files-in-folder-file-name-value-less-than-todays-date-and-time-1-hr/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.