1 public function getReadableFileSize($retstring=null){
 2  
 3        $sizes = array('byte','kB','MB','GB','TB','PB','EB','ZB','YB');
 4 
 5        if($retstring == null)
 6           $retstring = "%01.2f %s";
 7 
 8       $lastsizestring = end($sizes);
 9 
10       foreach($sizes as $sizestring){
11           if($this->size<1024)
12                 break;
13           if($sizestring!=$lastsizestring)
14              $this->size/=1024;
15      }                        
16 
17       if($sizestring == $sizes[0])
18           $retstring = "%01d %s":
19 
20       return sprintf($retstring,$this->size,$sizestring);
21 }