macromedia.coldfusion.cfml_general_discussion
[Top] [All Lists]

Re: Listing Files and Directories

Subject: Re: Listing Files and Directories
From: "Vidikron" <webforumsuser@xxxxxxxxxxxxxx>
Date: Wed, 30 Jul 2008 17:29:51 +0000 (UTC)
Newsgroups: macromedia.coldfusion.cfml_general_discussion

Could you give me a rough example?  I didn't write the current page and the 
person that did is no longer here.   Here's the code that thepage is currently 
using.

 The "target" variable is being passed in the URL.  It's just the top level 
directory where the listing of the files begins.  "Morpheus" is our internal 
web server.

 <cfif target NEQ "">
        <cfdirectory action="list" filter="*.*" recurse="no" 
directory="#GetDirectoryFromPath(GetTemplatePath())#/#target#" sort="name ASC, 
size DESC" name="rstDirectory">
        <cfif rstDirectory.recordcount NEQ 0>
                <cfoutput>
                        <table width="100%">
                                <tr>
                                        <td>
                                                <cfset counter = 1>
                                                <cfset counterBack = 1>
                                                <cfloop query="rstDirectory">

                                                        <cfif counter EQ 1>
                                                                <table 
align="left" <cfif style_page EQ 
"3col_leftNav">width="50%"</cfif>>
                                                        </cfif>

                                                        <cfif counter EQ 
Ceiling(rstDirectory.recordcount / 2) + 1>
                                                                <cfif 
style_page EQ "3col_leftNav">
                                                                        </table>
                                                                        <table 
align="right" width="50%">
                                                                </cfif>
                                                                <cfset 
counterBack = 2>
                                                        </cfif>

                                                        <cfif counter EQ 
rstDirectory.recordcount + 1>
                                                                </table>
                                                        </cfif>

                                                        <tr>
                                                                <td 
class="TableText" bgcolor="###Iif(counterBack MOD 2 EQ 0, 
DE('D5EAE9'), DE('FFFFFF'))#">
                                                                        <a 
href="http://morpheus/mi/#target#/#rstDirectory.name#"; title="File 
Date: #DateFormat(rstDirectory.dateLastModified, 'dddd, mmm dd, 
yyyy')#"><strong>#rstDirectory.name#</strong></a>
                                                                </td>
                                                        </tr>
                                                <cfset counter = counter + 1>
                                                <cfset counterBack = 
counterBack + 1>
                                        </cfloop>
                                </td>
                        </tr>
                </table>
                </cfoutput>
                <cfelse>
                There are no files to display.
        </cfif>
        <cfelse>
        <cflocation addtoken="no" url="http://morpheus/";>
 </cfif>


<Prev in Thread] Current Thread [Next in Thread>