Jump to content

delete images stored in a directory


dadamssg

Recommended Posts

Store the date in the filename, like so:

 

"mysuperawesomeuploadedfile_7-19-09.gif"

 

Aaaand thennn,

 

<?php

$handle = opendir('/path/to/file');

while (false !== ($filename = readdir($handle)))
{
        $splitFileName = explode('_', $filename);
        
        if (end($splitFileName) < date(n-j-y))
        {
        unlink($filename);
        }
}
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.