Skip to main content
October 1, 2008
Question

Help needed displaying images in file

  • October 1, 2008
  • 1 reply
  • 241 views
I have a directory of photographs that I wish to display one in a main folder and one in a folder called thumbs. Now there will always be a thumbs counterpart to the original image so for example I would like to display it:

<a href="123.jpg"><img src="thumbs/123.jpg"><br />123.jpg</a>

How can I have cold fusion cycle through files in a directory and do this for me?
    This topic has been closed for replies.

    1 reply

    Participating Frequently
    October 1, 2008
    The CF tag you're going to use to do this is cfdirectory.
    http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=Tags_d-e_03.html#1097918

    <cfdirectory directory="C:/My/Dir" name="dirQuery" action="LIST">
    <cfloop query="dirQuery">
    <cfif dirQuery.type IS "file"> <!--- this filters out other directories (folders) from the output --->
    <a href="#name#"><img src="thumbs/#name#"><br/>#name#</a>
    </cfif>
    </cfloop>