我想从特定类别中删除超过特定年龄(例如 2 个月)的图像。
如果我使用以下代码,这些图像位于某个目录中:
<?php
// define the directory
$dir = "images/";
// cycle through all files in the directory
foreach (glob($dir."*") as $file) {
// if file is 2 Month (5.184e+6 seconds) old then delete it
if (filemtime($file) < time() - 5.184e+6) {
unlink($file);
}
}
?>
然后它会删除所有 2 个月大的图像,但我想按类别删除图像。
这是我数据库中的一个表:
------------------------------------
table msn_story_images
------------------------------------
ID image(url) thumbnail sortstyID
图片文件夹非常大(大约 19GB),无法在服务器上列出。