Skip to content

Instantly share code, notes, and snippets.

@seanvree
Created April 11, 2018 20:46
Show Gist options
  • Save seanvree/fb2fb282ad49fa46d8fb4378e0147e3f to your computer and use it in GitHub Desktop.
Save seanvree/fb2fb282ad49fa46d8fb4378e0147e3f to your computer and use it in GitHub Desktop.
drive.php
<?php
// $df contains the number of bytes available on "/"
$df = disk_free_space("/");
// On Windows:
$df_c = disk_free_space("C:");
$df_d = disk_free_space("Z:");
echo "df: " . $df;
echo "<br>";
echo "df_c: " . $df_c;
echo "<br>";
echo "df_Z: " . $df_d;
if (PHP_OS == 'WINNT') {
$disk = "Z:";
echo "<br>";
echo "OS: " . PHP_OS;
}
else {
$disk = "/dev/sda1";
echo "<br>";
echo "OS: " . PHP_OS;
}
//hdd stat
$stat['hdd_free'] = round(disk_free_space($disk) / 1024 / 1024 / 1024, 2);
$stat['hdd_total'] = round(disk_total_space($disk) / 1024 / 1024/ 1024, 2);
$stat['hdd_used'] = $stat['hdd_total'] - $stat['hdd_free'];
$stat['hdd_percent'] = round(sprintf('%.1f',($stat['hdd_used'] / $stat['hdd_total']) * 100), 2);
$stat['hdd_percent'];
echo "<br>";
echo $disk . " percent free: " . $stat['hdd_percent'];
echo "<br>";
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment