php在Windows下获取文件夹和大文件大小

// 得到文件夹大小,$dir = 'F:/wamp/www/folder';
function getFolderSize($dir)
{	
    $obj = new COM ( 'scripting.filesystemobject' );
    if ( is_object ( $obj ) )
    {
        $ref = $obj->getfolder ( $dir );
        $size = $ref->size;
        $obj = null;
    }
    /*
    else
    {
        //echo 'can not create object';
    }
    */
    return $size;
}

// 获取大文件大小
/*
$file = 'C:\\system_backup.zip';
$size = real_filesize($file);
echo "The size of the file is: $size";
*/
function real_filesize($file_path)
{
    $fs = new COM("Scripting.FileSystemObject");
    return $fs->GetFile($file_path)->Size;
}

用PHP读取文件的正确方法

http://www.ibm.com/developerworks/cn/opensource/os-php-readfiles/

你可能感兴趣的:(PHP,filesize)