Get available disk space using php

by Mohan 2014-03-11 12:49:47


Get available disk space using php


Simple code to get available disk space in system or server space using php.
<?php
$bytes = disk_free_space(".");
$si_prefix = array( 'B', 'KB', 'MB', 'GB', 'TB', 'EB', 'ZB', 'YB' );
$base = 1024;
$class = min((int)log($bytes , $base) , count($si_prefix) - 1);
echo $bytes . '<br />';
echo sprintf('%1.2f' , $bytes / pow($base,$class)) . ' ' . $si_prefix[$class] . '<br />';
?>

Tagged in:

1053
like
0
dislike
0
mail
flag

You must LOGIN to add comments