I want make a loop of my fold, get all the files and make a judge, print all the files name witch size are less than 10kb. But I get nothing from this code (no php error hint, just 0 result, and I am sure there has 10 files at lest < 10kb), where is the problem? Thanks.
$folder = dirname('__FILE__')."/../images/*";
foreach(glob($folder) as files){
$size = filesize(files);
if($size<10240){
echo files.'<br />';
}
}
I think there's a typo, because
dirname('__FILE__')
should be (without quotes)
dirname(__FILE__)
and also, your variable files
doesn't have a dollar sign
$size = filesize($files);
and also here echo $files
That's it, it should fix your problem