Not yet rated

Problem

You are using cfdirectory to list the contents of a directory but you only want certain file types. Most people know that you can put in a single wildcard filter. In this example we will look at how to add multiple filters

Solution

You can add multiple filters using the pipe | operator.

Detailed explanation

 This example will grab all of the .jpg images from our images directory.


<cfdirectory
action="list" directory="c:\www\images" filter="*.jpg"
name="myimages">

This example will grab more image types from a directory. 


<cfdirectory
action="list" directory="c:\www\images" filter="*.jpg|*.gif|*.png"
name="myimages">


+
This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License. Permissions beyond the scope of this license, pertaining to the examples of code included within this work are available at Adobe.

Report abuse

Related recipes