2 Replies Latest reply on Jun 1, 2007 7:47 AM by Newsgroup_User

    Search on files names in directory

    Level 7
      Hello - I have a client who is wanting to allow visitors to search for
      files (by file name only) within a particular directory. The results
      page would then show a link to the document which could be a .pdf or a
      .doc. What is the best way to handle this search?

      Any help would be appreciated.

      Thank you,
      Steve Miller
        • 1. Re: Search on files names in directory
          craigkaminsky Level 3
          You can use cfdirectory for this. It returns a query, with one of the columns being "name".

          <cfdirectory directory="#fullPathToDirectory#" action="list" name="qryFiles"/>

          If you are not familiar with what gets returned, use cfdump when you are testing it so that you can see both directory contents but the column names as well:
          <cfdump var="#qryFiles#"/>

          From here, you can output results from the directory search as you would a 'normal' query.

          <cfoutput query="qryFiles">
          <a href="#qryFile.name#">#qryFile.name#</a><br/>
          </cfoutput>

          etc...

          Hope this helps!
          Craig
          • 2. Re: Search on files names in directory
            Level 7
            Craig you rock! That's exactly what I needed.

            Thank you,
            Steve Miller

            craigkaminsky wrote:

            >You can use cfdirectory for this. It returns a query, with one of the columns
            >being "name".
            >
            > <cfdirectory directory="#fullPathToDirectory#" action="list" name="qryFiles"/>
            >
            > If you are not familiar with what gets returned, use cfdump when you are
            >testing it so that you can see both directory contents but the column names as
            >well:
            > <cfdump var="#qryFiles#"/>
            >
            > From here, you can output results from the directory search as you would a
            >'normal' query.
            >
            > <cfoutput query="qryFiles">
            > <a href="#qryFile.name#">#qryFile.name#</a><br/>
            > </cfoutput>
            >
            > etc...
            >
            > Hope this helps!
            > Craig
            >
            >
            >