We will use the showFileOpenDialog() method to show up the FileDialog to choose the file to the user. Here, User can choose any file. But, Can we specify the file formats, so that user can choose only files of the specified file foramts(such as .jpg,.jpeg,.gif,.png etc.).
It is possible to specify a filter array, check the sample code of showFileOpenDialog():
// this selects only files '1', previous dir must be used 'null', no multiselect 'false' and
// the filter "JPG and GIF" should be used: 'new Array("JPG and GIF","jpg","gif")'
var file = plugins.file.showFileOpenDialog(1,null,false,new Array("JPG and GIF","jpg","gif"));
It seems that if I provide a file type as filter, I see no directories anymore. So the filter also applies to folders and filters them away because they don’t match. Can this be fixed?