CFDirectory Multiple Filters
Wednesday May 7, 2008 9:48 AM
Word Count: 283
As you can see from the example above the entire directory is listed. The directory contains png,cfm & cfc file extensions. If we wanted to list just the png files we could apply a filter to the results.
<cfset filters = "*.png">
<cfdirectory action="list" directory="#ExpandPath('.')#/cfgrid"
filter="#filters#" listinfo="name" name="dir">
<cfdump var="#dir#">
<cfdirectory action="list" directory="#ExpandPath('.')#/cfgrid"
filter="#filters#" listinfo="name" name="dir">
<cfdump var="#dir#">
I was always told that you could only filter by one file extension. In fact this is right from the docs which would really back up that statement.
File extension filter applied to returned names, for example, *.cfm. One filter can be applied.As I noted earlier you learn something new everyday. Here is an example of how to create multiple filters.
<cfset filters = "*.cfm|*.cfc">
<cfdirectory action="list" directory="#ExpandPath('.')#/cfgrid" filter="#filters#" listinfo="name" name="dir">
<cfdump var="#dir#">
<cfdirectory action="list" directory="#ExpandPath('.')#/cfgrid" filter="#filters#" listinfo="name" name="dir">
<cfdump var="#dir#">
