Re: Determining File Size

From: Date: Tue, 24 Jul 2001 22:39:30 +0000
Subject: Re: Determining File Size
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-59447@lists.php.net to get a copy of this message
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 "; Have fun! -bob -- Bob Scott Web / DB Developer http://www.covalent.net Covalent Technologies, Inc. On Tue, 24 Jul 2001, Alnisa Allgood wrote: > Hi: > > I've set-up a library/clearinghouse system that basically allows to > add papers and materials to a small member only resource library. I'd > like to be able to determine the file's size so that it's displayed > next to the item, so that people can gage how long it will take to > download items. This seems particularly relevant for some of the > older material included, since they consist of abnormally large PDF > files (they scanned paper to image, then converted to PDF) > > Is the best method for handling this to determine the file size at > upload, and then send the information to MySQL, or some other method. > > 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 > ......................................... > > -- > 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 > >

« previous php.general (#59447) next »