Users running a non-download version of Vanilla (pulled from github), on branch release/2019.016 or master from the last 2 weeks should upgrade to release/2019.017 or latest master for security reasons. Downloaded official open sources releases are not affected.

remove uploaded attachments older then 30 days

jackmaessenjackmaessen ✭✭✭
edited March 2015 in General Banter

I am experimenting with this piece of code to automatically remove files (uploaded files like attachments) when they are older then 30 days.


/*** 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...



Sign In or Register to comment.