作者:mobiledu2402851203 | 2023-08-31 15:22
以下是其他解决方案的其他地方提供:
如果在Windows主机上:
$f = 'f:/www/docs';
$obj = new COM ( 'scripting.filesystemobject' );
if ( is_object ( $obj ) )
{
$ref = $obj->getfolder ( $f );
echo 'Directory: ' . $f . ' => Size: ' . $ref->size;
$obj = null;
}
else
{
echo 'can not create object';
}
?>
否则,如果在Linux主机上:
$f = './path/directory';
$io = popen ( '/usr/bin/du -sk ' . $f, 'r' );
$size = fgets ( $io, 4096);
$size = substr ( $size, 0, strpos ( $size, "\t" ) );
pclose ( $io );
echo 'Directory: ' . $f . ' => Size: ' . $size;
?>
vdbuilder..
27
一个纯PHP的例子.
");
echo('diskspace used: ' . format_size($disk_used) . '
');
echo( 'diskspace left: ' . format_size($disk_remaining) . '
');
echo("