Hi,

The script below displays directories/files on the server using <cfdirectory etc. How can I incorporate a <cfftp with the below code which also allows the drilldown etc.

--HTML--
<HEAD>
<title>Directory Listing</title>

<style>
.dlinks {font-family:arial, verdana, helvetica, sanserif;font-weight:normal;font-size:12px; }
a:hover { color:#FF9900 }
A { text-decoration: none }
</style>
</HEAD>

<BODY text="#000000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" link="#333366" vlink="#333366" alink="#333366">

<cfscript>

// Copy form and URL variables to attributes scope
if (NOT IsDefined("attributes")) attributes = StructNew();
if (IsDefined("form")) StructAppend(attributes,form,"yes");
if (IsDefined("url")) StructAppend(attributes,url,"yes");

// Expected parameters
variables.defaultdrive = "d:";
if (NOT IsDefined("attributes.directorypath")) attributes.directorypath=variables.defaultdrive&"\";
attributes.directorypath = URLDecode(attributes.directorypath);
if (NOT IsDefined("attributes.indent")) attributes.indent = 1;

// use this to make sure the display tables have enough columns
variables.leftoverindent = ListLen(attributes.directorypath,"\")-attributes.indent+1;
if (variables.leftoverindent LT 0) variables.leftoverindent = ListLen(attributes.directorypath,"\")+1;

// default variables
variables.currentpath = "";
variables.nextfolder = "";
variables.ignorelist = ".,..";

// Set up the information required for the display of this level
for (i=1; i lte attributes.indent; i=i+1)
currentpath = ListAppend(currentpath,ListGetAt(attributes.directorypath,i,"\"),"\");

if (attributes.indent LT listlen(attributes.directorypath,"\"))
variables.nextfolder = ListGetAt(attributes.directorypath,attributes.indent+1,"\");
</cfscript>

<cfdirectory action="" directory="#variables.currentpath#" name="DirListing" sort="type ASC, name ASC">

<cfoutput query="DirListing">
<cfsilent>
<cfscript>
// Set up the next path
nextpath = variables.currentpath&"\"&name&"\";
nextindent = attributes.indent +1;

updir = listdeleteat(variables.currentpath,listlen(variables.currentpath,"\"),"\") & "\";
</cfscript>
</cfsilent>
    <cfif attributes.indent EQ 1>
        <cfif DirListing.type IS "dir" AND ListFindNoCase(variables.ignorelist,dirlisting.name) EQ 0>
<!--- Display restricted top level --->
<TABLE CELLPADDING="0" CELLSPACING="0" BORDER="0">

<cfif  DirListing.name eq variables.nextfolder> <!--- Display Expanded Folder --->
<TR>
<TD colspan="#attributes.indent#">&nbsp;</TD>
<TD valign="middle" width="16" height="13"><A href="" alt="Back"><IMG src=""
width="16" border="0" alt="Back"></A></TD>
<TD colspan="#leftoverindent#">&nbsp;<A href="" alt="Back"><FONT class="dlinks">#dirlisting.name#</FONT>
</A></TD>
</TR>

<cfmodule template="listing.cfm" directorypath="#attributes.directorypath#" indent="#nextindent#">
<cfelse>
<!--- Display collapsed folder --->
<TR>
<TD colspan="#attributes.indent#">&nbsp;</TD>
<TD width="16" height="13"><A href="" class="dlinks" alt="#dirlisting.name#"><IMG src="" border="0"></A></TD>
<TD colspan="#leftoverindent#" align="left">
<!--- Display directory folders --->
&nbsp;<A href="" class="dlinks" alt="#dirlisting.name#">#dirlisting.name#</A>
</TD>
</TR>
</cfif>
         </cfif>
<cfelse> <!--- Display Directory 2nd level + --->
<cfif DirListing.type IS "dir" AND ListFindNoCase(variables.ignorelist,dirlisting.name) EQ 0>
<cfif  DirListing.name eq variables.nextfolder> <!--- Display Expanded Folder --->
<TR>
<TD colspan="#attributes.indent#">&nbsp;</TD>
<TD valign="middle" width="16" height="13"><A href="" alt="Back"><IMG src=""
width="16" border="0" alt="Back"></A></TD>
<TD colspan="#leftoverindent#">&nbsp;<A href="" alt="Back"><FONT class="dlinks">#dirlisting.name#</FONT>
</A></TD>
</TR>

<cfmodule template="listing.cfm" directorypath="#attributes.directorypath#" indent="#nextindent#">
<cfelse>
<!--- Display collapsed folder --->
<TR>
<TD colspan="#attributes.indent#"></TD>
<TD valign="middle" width="16" height="13"><A href="" class="dlinks" alt="#dirlisting.name#"><IMG src="" border="0"></A></TD>
<TD colspan="#leftoverindent#" align="left">
<!--- Display directory folders --->
&nbsp;<A href="" class="dlinks" alt="#dirlisting.name#">#dirlisting.name#</A>
</TD>
</TR>
</cfif>

<cfelseif ListFindNoCase(variables.ignorelist,dirlisting.name) EQ 0> <!--- Display File --->
<TR height="20">
<TD colspan="#attributes.indent#">&nbsp;</TD>
<TD width="18" height="20">&nbsp;</TD>
<TD valign="middle" height="20" class="dlinks" colspan="#evaluate(leftoverindent+1)#">
<!--- Display file names --->
<font class="dlinks"><a href=""> </TD>
</TR>

</TABLE>
</cfif>

    </cfif>
</cfoutput>

</body>
--/html--


[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

Reply via email to