note 9362 added to filesize
| From: | davidwuman at hotmail dot com | Date: | Sun, 29 Oct 2000 10:21:02 +0000 |
| Subject: | note 9362 added to filesize | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-7170@lists.php.net to get a copy of this message | ||
Here is a neater function that allows you to convert a given local file into either bytes,
kilobytes, or megabytes.
// -----------------------------------------------------------------
// FUNCTION getSize
// -----------------------------------------------------------------
function getSize($file, $unit) {
$inbytes = filesize($file);
$inkilobytes = $inbytes / 1024;
$inmegabytes = $inkilobytes / 1024;
if (($unit=="k") || ($unit=="K")) {
$fsize = $inkilobytes;
} elseif (($unit=="m") || ($unit=="M")) {
$fsize = $inmegabytes;
} else {
$fsize = $inbytes;
}
return $fsize;
}
http://www.php.net/manual/function.filesize.php