I want delete files less than a particular size say 10kb. how do I do it in PHP??
Like so, for example:
foreach (glob('/path/to/files/*') as $file) {
if (is_writable($file) && filesize($file) < (1024 * 10)) {
unlink($file);
}
}
To check size of file you need use this link. Here you got how list files in directory. Here you got documentation of readdir.
Using those links should help you.
Hope this might help:
<?php
// outputs e.g. somefile.txt: 1024 bytes
$filename = 'somefile.txt';
if(filesize($filename) == (10*1024)){
unlink($filename);
}
?>