Most ColdFusion functions, like cfdirectory, return file size information in bytes. While that is probably a more technically accurate number, it usually doesn’t mean a whole heck of a lot to end users, who are probably more used to “denominations” such as the kilo or megabyte. I remedy this, I whipped up the following helper function.

Basic usage: fileSizeFormat(size)

If you need to show file sizes larger that GB, you could easily add 1024^4 and 1024^5 to the above if statement. Either that or seriously start looking into compression.