Created
July 3, 2017 11:47
-
-
Save ahmethakanbesel/883cb762406cc77391807dbe97eb3d91 to your computer and use it in GitHub Desktop.
PHP ile eski dosyaları silme (Delete files older than X in PHP)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* Silinecek dosyaların bulunduğu dizin | |
*/ | |
$dir = "klasor/dosyalar"; | |
/* | |
* Dizindeki tüm dosyalara işlem uygulanır | |
*/ | |
foreach (glob($dir."*") as $file) { | |
/* | |
* 1 gün = 24 saat = 86400 saniye (bir günden eski tüm dosyaları siler | |
*/ | |
if(time() - filectime($file) > 86400){ | |
unlink($file); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment