CFMU File Filters
After a quick release this morning of my new multiple file upload component Todd Sharp pointed out that I should allow for custom file filters. I knew this would be an easy addition but I wanted to get out a alpha release this morning. When I got home I came up with a pretty quick but effective solution. So if your not familiar with what a file filter is I will give you a quick explanation. When you open a native file chooser on your OS you can control what types of files there are allowed to browse for.
In Action Script these are defined by using the FileFilter class. Here is a quick example of how you would do it, this was browse method before the change. The first argument is the description that is displayed to the user and the 2nd argument is an actual list of extensions using a semi colon delimiter that they can choose from. The important thing to notice is that the browse method takes an array of filters. If you have 1 its a single element if you had 0 it could be an empty array.
Now that you know what they are and how they work I can show you how I made them dynamic. With the uploader component there is a xml settings file. In the settings file I added a filters attribute that looked this.
Then I wrote a simple parser method to build the file filters array and return it back to my main application. The great thing here is that we are creating an empty array and returning that no matter what. This means if the user has no filters it will return an empty array and an empty array is basically attaching NO restrictions, the user can select what ever they want.
Here is a quick screen shot of multiple file filters from my xml above.

