我正在尝试对指定路径中所有目录的输出以及每个目录中的文件进行分组。目前,我有:
<cfset local.baseWebPath = ExpandPath( "./upload/views/files/" ) />
<cfset custID = session.authUser.getuser_custid() />
<cfset filters = "*.pdf|*.zip|*.doc*|*.ppt*|*.pps*|*.ai*|*.eps*|*.xls*|*.swf|*.rtf|*.psd|*.jpg|*.png|*.tif">
<!---display directory for specific customer--->
<cfdirectory
action = "list"
directory = "#local.baseWebPath##left(custID, 5)#"
name = "getFiles"
filter = "#filters#"
recurse = "no"
/>
<cfoutput query="getFiles">
<!---get the file name--->
<cfset fname = ListFirst(getFiles.name, "." )>
<!---get the file extenstion--->
<cfset exten = ListLast(getFiles.name, ".")>
<cfif getFiles.type eq "file" and getFiles.name neq "thumbs.db">
<tr>
<td align="absmiddle"><a href="#buildUrl('main.attachDownload?filename=#getFiles.name#')#">#fname#</a></td>
<td align="absmiddle"><img src="/art/assets/images/fileTypes/#fileIcon#" title="#exten#"/></td>
<td align="absmiddle">
<!---convert the file size from bytes into mb and kb--->
<cfif getFiles.size GT "1000000">
#numberformat(getFiles.size*.000001, 9.99)#Mb
<cfelse>
#numberformat(getFiles.size*.001, 9)#kb
</cfif>
</td>
<td align="absmiddle">#getFiles.dateLastModified#</td>
<td align="absmiddle"><a href="#buildUrl('main.deleteFile?filename=#getFiles.name#')#" onClick="alert('Are you sure you want to delete this file?')"><img src="/art/assets/images/delete.png" title="delete file" /></a></td>
</tr>
</cfif>
</cfoutput>
<!---display all directories and their files for admin--->
<cfdirectory
action="list"
directory="#local.baseWebPath#"
name="allDirectories"
recurse="true"
/>
显示单个客户目录效果很好。但是,当管理员登录时,应显示所有目录以及按客户分组的文件。我怎样才能做到这一点?