• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Search on files names in directory

LEGEND ,
Jun 01, 2007 Jun 01, 2007

Copy link to clipboard

Copied

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
TOPICS
Advanced techniques

Views

248

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Jun 01, 2007 Jun 01, 2007

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 01, 2007 Jun 01, 2007

Copy link to clipboard

Copied

LATEST
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
>
>
>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation