note 9362 deleted from function.filesize by jimw

From: Date: Fri, 14 Dec 2001 20:15:52 +0000
Subject: note 9362 deleted from function.filesize by jimw
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-22714@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; }

« previous php.notes (#22714) next »