[Jump to Content]
This site will look much better in a browser that supports web standards, but is accessible to any browser or Internet device. Why does this site look bad in Netscape 4?
Information Technology Academic Technologies Computer Services Media Services
University of Washington Tacoma homepage
IT Help
Computer Services brings together skills, knowledge, hardware & software, and commitment to provide a customer centered support service. Remote File Access (RFA) MS Campus Agreement Wireless Local Area Network
Remote File Access (RFA) MS Campus Agreement Wireless Local Area Network
[Content]

Displaying file size (getFileSize)

Custom Tag: cf_getFileSize

This tag allows you to automatically display the file size of any file on the web server. This comes in handy for large files such as PDFs, high-resolution graphics, or multimedia files. Stating the file size helps warn users that the file could take a long time to download.

Usage

The following generic tag:

<cf_getFileSize 
	rel_path="relative_path_to_the_file" 
	file_name="filename.extension"
>

populated with an actual relative path and file name:

<cf_getFileSize 
	rel_path="../construction_projects/" 
	file_name="UWTPhase3Programming.pdf"
>

will produce output like this:

You must add your own parenthesis, etc.

Oh, and notice that cf_icon is used to generate the PDF icon. :-)

Disc storage units and accuracy

The tag will automatically display the file size in Gigabytes (GB), Megabytes (MB), Kilobytes (KB), or Bytes (B) as appropriate. Units may not be specified; the script chooses the largest unit having a value greater than or equal to one. Megabytes and Gigabytes are expressed to two decimal places. Kilobytes and Bytes are rounded to the nearest integer. Calculations are based on the following binary prefixes external Web site :

  • 1 GB = 1,024 MB = (2^30 B) = 1024³ B
  • 1 MB = 1,024 KB = (2^20 B) = 1024² B
  • 1 KB = 1,024  B = (2^10 B) = 1024¹ B