0 Replies Latest reply on Jan 16, 2007 11:26 AM by lusciousmango

    <CFDIRECTORY> problem, I think

    lusciousmango Level 1
      I'm trying to build an application to house documents, and give moderators the ability to upload files into specific directories that they can determine. I've used code from the CFWACK 7 chapter 34 to display each folder's contents and to move among them.

      What I'd like is to display a list of current directories, allow the user to select one, and have the value of that selected directory pass, so that they can upload directly into it. I was trying to get the form to regenerate on the fly with that passed value, but it won't.

      Instead, I'm having the form loop back upon itself, hopefully with the passed directory, but I get the error " Element SUBFOLDERPATH is undefined in FORM." I'm guessing this is because I've mis-configured the <CFIF> statement at the top.

      Does anyone have any light they can shed?

      Here's what I've got (pretty much copied directly from the book):

      <!--- The user can explore this folder and any nested subfolders --->
      <CFSET baseFolder = expandPath("/KS/Library/Files/")>

      <!--- the SubfolderPath variable indicates the currently selected folder (relative to the BaseFolder). Defaults to an empty string, meaning that the BaseFolder will be current when the page first appears --->
      <CFIF FORM.SubfolderPath NEQ 0>
      <CFPARAM NAME="subfolderPath" type="string">
      <CFPARAM name="subfolderPath" type="string" default="">

      <!--- This variable, then, is the full path of the selected folder --->
      <CFSET folderToDisplay = baseFolder & subfolderPath>

      <!--- Get a listing of the selected folder --->
      sort="Name ASC"

      <CFOUTPUT query="directoryQuery">
      <!--- Create a simple form for navigating through folders --->
      <FORM action="index.cfm?fuseaction=Library.ChooseDir" method="post" >

      <!--- Show the subfolder path, unless already at the top level --->
      <CFIF subfolderPath EQ "">
      You are at the top level.<BR>
      Current Folder: #subfolderPath#<BR>

      <!--- Provide a drop-down list of subfolder names --->
      Select destination 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>

      <!--- 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="#Name#">#Name#</OPTION>