Development

Changeset 2470

You must first sign up to be able to contribute.

Changeset 2470

Show
Ignore:
Timestamp:
10/21/06 04:13:01 (7 years ago)
Author:
erestar
Message:

erestar: added a file size parser to be use in sfPropelFileStorageAdmin module.
Thanks to: http://www.php.net/manual/en/function.filesize.php#64387

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • plugins/sfPropelFileStoragePlugin/lib/sfPropelFileStorageUtil.class.php

    r2441 r2470  
    8787    return null; 
    8888  } 
     89   
     90 
     91  /* Thanks to: http://www.php.net/manual/en/function.filesize.php#64387 */ 
     92  public static function parse_file_size($size){ 
     93  /* 
     94  Returns a human readable size 
     95  */ 
     96    $i=0; 
     97    $iec = array("B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"); 
     98    while (($size/1024)>1) { 
     99     $size=$size/1024; 
     100     $i++; 
     101    } 
     102    return substr($size,0,strpos($size,'.')+4).' '.$iec[$i]; 
     103  } 
     104  // Usage : size_hum_read(filesize($file)); 
     105 
    89106} 
    90107?>