note 3455 deleted from function.filesize by jimw

From: Date: Fri, 14 Dec 2001 20:14:30 +0000
Subject: note 3455 deleted from function.filesize by jimw
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-22706@lists.php.net to get a copy of this message
here's a nifty thing to have the filesize rounded to 2 decimals, AND display size in bytes/kilo/meg/gig depending on filesize.. (dunno if this could be cut down, but it's at least a start) --- cut --- <pre> $file_size = filesize(<FILENAME>); if ($file_size >= 1073741824) { $file_size = round($file_size / 1073741824 * 100) / 100 . "g"; } elseif ($file_size >= 1048576) { $file_size = round($file_size / 1048576 * 100) / 100 . "m"; } elseif ($file_size >= 1024) { $file_size = round($file_size / 1024 * 100) / 100 . "k"; } else { $file_size = $file_size . "b"; } </pre> --- end cut --- have fun with this.. jesse. mail, jesse@jess.on.ca http, www.jess.on.ca

« previous php.notes (#22706) next »