views:

49

answers:

1

I have a large list with icons linking to pdf and msword files. I'd like to get the filesize in kb of the linked file then use that as the alt attribute on the image. The generated code would look something like this.

Description of file <a href="file1.pdf"><img src="pdficon.gif" alt="27.6 kb" /></a> 
<a href="file1.doc"><img src="wordicon.gif" alt="33.2 kb" /></a>

All the links to the files are static href's as not all the files in the directory are used in this list. How would I go about doing in coldfusion? Would I have to get all the files using cfdirectory and then match them up with the href's? Or is there a way to just parse the parent href and grab the filesize?

Thanks!

+4  A: 

Time to use Java

<cfset file = createObject("java","java.io.File").init("/directoy/filename")>
<cfset fileSizeInKB = file.length() / 1024>
Henry
I have a suspicion that using the cfdirectory approach he mentioned may be faster though.
Tyler Clendenin