我的表单允许用户选择一个目录来查看其中包含的文件:
(文件.cfm)
<form action="#buildURL('main.files')#" method="post">
<!--- Show the subfolder path, unless already at top level --->
<cfif subfolderPath EQ "">
<h2>You are at the top level.</h2>
<cfelse>
<h2>Current Folder: #subfolderPath#</h2>
</cfif>
<!--- Provide a drop-down list of subfolder names --->
Select folder:
<select name="subfolderPath" onChange="this.form.submit()">
<!--- Provide an option to go up one level to the parent folder, --->
<!--- unless already at the BaseFolder --->
<cfif listLen(subfolderPath, "/") gt 0>
<cfset parentFolder = listDeleteAt(subfolderPath, listLen(subfolderPath, "/"), "/")>
<option value="#parentFolder#">[parent folder]</option>
</cfif>
<!--- For each record in the query returned by <cfdirectory> --->
<cfloop query="DirectoryQuery">
<!--- If the record represents a subfolder, list it as an option --->
<cfif Type eq "Dir">
<option value="#subfolderPath#/#Name#">#Name#</option>
</cfif>
</cfloop>
</select>
<!--- Submit button to navigate to the selected folder --->
<input type="submit" value="go">
</form>
显示文件时,有一个删除功能会调用另一个页面:
<td align="absmiddle"><a href="#buildUrl('main.deleteFile?filename=#name#&folder=#rereplace(subFolderPath, '/','')#')#" onClick="alert('Are you sure you want to delete this file?')"><img src="/art/assets/images/delete.png" title="delete file" /></a></td>
在 deleteFile 页面 (deleteFile.cfm) 上,文件被删除:
<cfset local.filePath = ExpandPath( ".\upload\views\files\#rereplace(url.folder, '/','')#\" ) />
<cffile action="delete"
file="#local.filePath##url.filename#"
/>
然后用户被送回上一页:
<cflocation url="#buildUrl('main.files')#" />
但不在刚刚删除文件的目录的同一视图中。如何将用户返回到文件页面并维护他所在目录的视图?