我想從特定類別中刪除超過特定年齡(例如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 –