Return to Snippet

Revision: 17493
at September 7, 2009 18:33 by scopefragger

Initial Code
echo (filesize_r($path)/1048576)." MB / ". $diskspace;
function filesize_r($path){
  if(!file_exists($path)) return 0;
  if(is_file($path)) return filesize($path);
  $ret = 0;
  foreach(glob($path."/*") as $fn)
    $ret += filesize_r($fn);
  return $ret;

Initial URL

Initial Description
Ever wanted to give your cliant an idear on how much disk space they have remaining?  The following script will tell your user how much disk space has been used and how much is remaining.  In this example $diskspace refers the amount of diskspace your cliant has avalable.  

The value of disk space can be changed to suite,  if required this value can my connected to a mysql_query.  Such as if you are running a hosting service, have the value pulled from your hosting database.

If you dont wish to include a /mb  removed the "." MB / ". $diskspace"  line 4

Initial Title
Find the size of a folder or directory

Initial Tags

Initial Language