for ($i = 67; $i <= 90; $i++)
{
$drive = chr($i);
if (is_dir($drive.':'))
{
$freespace = disk_free_space($drive.':');
$total_space = disk_total_space($drive.':');
$percentage_free = $freespace ? round($freespace / $total_space, 2) * 100 : 0;
echo $drive.': '.to_readble_size($freespace).' / '.to_readble_size($total_space).' ['.$percentage_free.'%]
';
}
}
function to_readble_size($size)
{
switch (true)
{
case ($size > 1000000000000):
$size /= 1000000000000;
$suffix = 'TB';
break;
case ($size > 1000000000):
$size /= 1000000000;
$suffix = 'GB';
break;
case ($size > 1000000):
$size /= 1000000;
$suffix = 'MB';
break;
case ($size > 1000):
$size /= 1000;
$suffix = 'KB';
break;
default:
$suffix = 'B';
}
return round($size, 2).$suffix;
}
?>
Monday, 27 July 2009
To get the disk space of your system using php
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment