remove uploaded attachments older then 30 days
jackmaessen
✭✭✭
I am experimenting with this piece of code to automatically remove files (uploaded files like attachments) when they are older then 30 days.
<?php
/*** folder to files ***/
$dir = "uploads/test/";
/*** loop through all the files in the folder ***/
foreach (glob($dir."*") as $file) {
/*** if files older then 30 days after upload; -> remove ***/
if (filemtime($file) < time() - 60*60*24*30) { // 30 days
unlink($file); // remove
}
}
?>
Only thing i don't know how to handle with is the attachment links in the comments; they are still there and they become dead links.
So i have to think of a way how to remove also automatically the links in the comments...
Tagged:
0
Comments
2 suggestions:
Also you'll need some kind of cron job to trigger this.
My themes: pure | minusbaseline - My plugins: CSSedit | HTMLedit | InfiniteScroll | BirthdayModule | [all] - PM me about customizations
VanillaSkins.com - Plugins, Themes and Graphics for Vanillaforums OS