Re: Determining File Size

From: Date: Wed, 25 Jul 2001 01:43:09 +0000
Subject: Re: Determining File Size
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-59472@lists.php.net to get a copy of this message
At 3:39 PM -0700 7/24/01, Bob Scott wrote:
There's a nifty little function called filesize()... I've done this before to make human-readable output: $my_file = "/path/to/my/file"; $file_size = filesize($my_file); if ($file_size >= 1073741824) {
        $show_filesize = number_format(($file_size / 1073741824),2) . "
GB"; } elseif ($file_size >= 1048576) {
        $show_filesize = number_format(($file_size / 1048576),2) . " MB";
} elseif ($file_size >= 1024) {
        $show_filesize = number_format(($file_size / 1024),2) . " KB";
} elseif ($file_size >= 0) {
        $show_filesize = $file_size . " bytes";
} else {
        $show_filesize = "0 bytes";
} echo "File $my_file is $show_filesize ";
Wow!! Can I be effusive!!! :) It worked like a charmed. I just added my path statement, and then placed the $show_filesize after the url to the document. It's beautiful!!! Thanks! Alnisa -- ......................................... Alnisa Allgood Executive Director Nonprofit Tech (ph) 415.337.7412 (fx) 415.337.7927 (url) http://www.nonprofit-techworld.org (url) http://www.nonprofit-tech.org (url) http://www.tech-library.org ......................................... Nonprofit Tech E-Update mailto:nonprofit-tech-subscribe@egroups.com ......................................... applying technology to transform .........................................

« previous php.general (#59472) next »