你的方法听起来不错。但是,您可以在没有数据库的情况下通过查看文件的创建日期来执行此操作;假设任何文件创建的时间都比您上次运行检查的时间晚,因此上周三之后创建的任何文件都是新文件。
$dirPath='/path/of/your/images';
$files=scandir($dirPath);
//assuming this is in fact once a week,
//adjust '$lastCheck' based on the schedule this will run
$lastCheck=strtotime("-7 day");
foreach($files as $file)
{
if (is_file("$dirPath/$file") && !is_link("$dirPath/$file") ) //make sure its not a directory or symlink
{
$createTime=filectime("$dirPath/$file");
//check if its older than a week
if ($createTime>$lastCheck)
{
//file is newer than a week
$newFiles[]="$dirPath/$file";
}
}
}
//now $newFiles has all the files from this week, with no DB interaction.