我想从特定类别中删除超过特定年龄(例如2个月)的图像。如何使用php删除一些较旧的图像?
这些图像位于某个目录里,如果我用下面的代码:
<?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),并且不能在服务器上列出。
你使用什么类型的数据库,以及如何访问它? – Fredd
我正在使用mysql –