# system.file.openFile - Several file extensions?

**URL:** <https://forum.inductiveautomation.com/t/system-file-openfile-several-file-extensions/23315>\
**Category:** Ignition\
**Created:** [March 13, 2019, 8:23pm UTC](https://forum.inductiveautomation.com/t/system-file-openfile-several-file-extensions/23315 "2019-03-13T20:23:07Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![pat.stave1](https://avatars.discourse-cdn.com/v4/letter/p/f19dbf/32.png) [@pat.stave1](https://forum.inductiveautomation.com/u/pat.stave1)\
**Post date:** [March 13, 2019, 8:23pm UTC](https://forum.inductiveautomation.com/t/system-file-openfile-several-file-extensions/23315/1 "2019-03-13T20:23:07Z")

</div>

Is it possible to call system.file.openFile() allowing the user to select more than one type of file extension?  
In my case i want the user to be able to select file types .JPG, .JPEG and .PNG

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [March 13, 2019, 8:45pm UTC](https://forum.inductiveautomation.com/t/system-file-openfile-several-file-extensions/23315/2 "2019-03-13T20:45:05Z")

</div>

Currently, no. But here is the link to the entry on the feedback forum.

[https://ideas.inductiveautomation.com/ignition-features-and-ideas/p/systemfileopenfile-add-the-ability-to-specify-multiple-file-extensions-for-filet](https://ideas.inductiveautomation.com/ignition-features-and-ideas/p/systemfileopenfile-add-the-ability-to-specify-multiple-file-extensions-for-filet)

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [March 13, 2019, 8:48pm UTC](https://forum.inductiveautomation.com/t/system-file-openfile-several-file-extensions/23315/3 "2019-03-13T20:48:43Z")

</div>

It’s not possible through the system function directly, unfortunately. Untested workaround solution:

```auto
from com.inductiveautomation.ignition.client.script import ClientFileUtilities

def openFiles(desc, *extensions):
	filechooser = ClientFileUtilities.getChooser(0, desc, *extensions)

	filechooser.setMultiSelectionEnabled(True)

	if filechooser.showOpenDialog(None) is not None:
		return [file.getPath() for file in filechooser.getSelectedFiles()]

def openFile(desc, *extensions):
	filechooser = ClientFileUtilities.getChooser(0, desc, *extensions)

	if filechooser.showOpenDialog(None) is not None:
		return filechooser.getSelectedFile().getPath()

# imageFiles = openFiles("Image (JPG, JPEG, PNG)", "jpg", "jpeg", "png")
# imageFile = openFile("Image (JPG, JPEG, PNG)", "jpg", "jpeg", "png")

```

---

<div class="post-metadata">

**Author:** ![code\_skin](https://avatars.discourse-cdn.com/v4/letter/c/43a26b/32.png) [@code\_skin](https://forum.inductiveautomation.com/u/code_skin)\
**Post date:** [April 26, 2019, 7:16pm UTC](https://forum.inductiveautomation.com/t/system-file-openfile-several-file-extensions/23315/4 "2019-04-26T19:16:10Z")

</div>

@paul-griffith, your code works as expected. One thing I noticed is when users click cancel it still returns the selected file paths. Any idea how I could get it to return None when a user selects files and then decides to cancel?

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [April 30, 2019, 4:55pm UTC](https://forum.inductiveautomation.com/t/system-file-openfile-several-file-extensions/23315/5 "2019-04-30T16:55:20Z")

</div>

@code_skin

```auto
	if filechooser.showOpenDialog(None) is not None:

```

can probably be changed to

```auto
	if filechooser.showOpenDialog(None) == 0:

```

where 0 is the ‘magic number’ representing `javax.swing.JFileChooser#APPROVE_OPTION`; see the constant field values reference: [https://docs.oracle.com/javase/7/docs/api/constant-values.html#javax.swing.JFileChooser.APPROVE\_OPTION](https://docs.oracle.com/javase/7/docs/api/constant-values.html#javax.swing.JFileChooser.APPROVE_OPTION)
