<?php
function get_allfiles($path,&$files) {
if(is_dir($path)){
$dp = dir($path);
while ($file = $dp ->read()){
if($file !="." && $file !=".."){
get_allfiles($path."/".$file, $files);
}
}
$dp ->close();
}
if(is_file($path)){
$files[] = $path;
}
}
function get_filenamesbydir($dir){
$files = array();
get_allfiles($dir,$files);
return $files;
}
$filenames = get_filenamesbydir("./hotels/hotelimg");
//删除指定文件
foreach ($filenames as $value) {
$filesize=abs(filesize($value));
if($filesize<10240){ //小于10K
echo $value."<br />";//输出被删除的文件名
unlink($value);
}
}
欢迎联系本站长QQ:3216572