Search code examples
htmlcoldfusion

CFloop through images in a local directory and display in HTML


I'm very new to ColdFusion, I am trying to pull image files from my PC's network directory and display them in an HTML table. This is what I have so far -

<cfdirectory action="list" directory="#ExpandPath('file://///network/path/Share-Install/path')#" name="listRoot">

        <cfoutput>

            <cfloop query="listRoot">
                // Build HTML table here maybe?
            </cfloop>

        </cfoutput>

If this code is correct its not clear to me how to work with the data brought back from the file/loop. Like I said I'm just now beginning with ColdFusion, so I appreciate any advise with this!


Solution

  • I was using the wrong approach and ended up getting the result I wanted by using <cfimage>. Here is my code that loops through my directory and displays the images in HTML table -

    <cfdirectory action="list" directory="C:\Share-Install\55555" name="listRoot" filter="*.jpg">
    
            <table width="100%">
                <tr>
                <cfloop query="listRoot">
                    <tr>
                        <td ><cfimage action="writetobrowser" source="/Share-Install/55555/#name#" width="300"></td>
                    </tr>
                </cfloop>
            </tr>
            </table>