I'm sorry for my ambiguity... let me see if I can shed light....
Follow this script (and read all comments as you go):
<?php
// Start by defining some constants
$dir = '/path/to/uploaded/files/';
// These define when a file should be "expired". How many hours, minutes,seconds
// or months, days from the current time should there be? Right now, it's set for 1 week
// If the file is older than 1 week, we will delete it.
$hours = 0;
$mins = 0;
$secs = 0;
$months = 0;
$days = 7;
$handle = dir($dir);
while(false !== ($entry = $d->read())){
if($entry != '.' && $entry != '..'){
if(!is_dir($dir.$entry)){
$files[] = $entry;
}
}
}
foreach($files as $file){
$mod_time = filemtime($dir.$file); // Gets the last modified date of the file
// Could also use filectime($dir.$file) to get when the file was last changed, rather
// rather than last modified. Depends on what you want
$expires = mktime(date('H')-$hours, date('i')-$mins, date('s')-$secs, date('m')-$months, date('d')-$days, date('Y'));
if($mod_time < $expires){
$del = unlink($dir.$file);
}
}
?>
Then, you go into your cPanel (or CronTab) and create a cronjob to run whenever you want (every day, every hour, every week) and point it to this script (with the MAILTO of course). Need help with cronjobs? Google it, there's plenty of help (including the Apache Documentation).
~Brett