Re: How do I get the file size of a file on my server?
| From: | Jeff Lewis | Date: | Tue, 28 Aug 2001 15:03:26 +0000 |
| Subject: | Re: How do I get the file size of a file on my server? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-64825@lists.php.net to get a copy of this message | ||
$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";
}
is a code snippet from the PHP manual which allows you to display the file
size rounded and then GB. MB, or KB :)
Use the absolute file path for the file you want looked at.
Jeff
----- Original Message -----
From: "Joseph Bannon" <JBannon@advparadigm.com>
To: "PHP (E-mail)" <php-general@lists.php.net>
Sent: Tuesday, August 28, 2001 10:37 AM
Subject: [PHP] How do I get the file size of a file on my server?
> How do I get the file size of a file on my server using PHP?
>
> Thanks,
> Joseph
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>
>
>