PHP

PHP – 檢查文件夾大小

<?php
/* http://tw.bestconverter.org/unitconverter_number.php */
$size = GetDirectorySize("folder_path");
if($size > 524288000){
   echo "folder size more than 500MB";
}
function GetDirectorySize($path){
    $bytestotal = 0;
    $path = realpath($path);
    if($path!==false && $path!='' && file_exists($path)){
        foreach(new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path, FilesystemIterator::SKIP_DOTS)) as $object){
            $bytestotal += $object->getSize();
        }
    }
    return $bytestotal;
}
?>

開始在上面輸入您的搜索詞,然後按回車進行搜索。按ESC取消。

返回頂部