# Bringing File Path into Text Field

**URL:** <https://forum.inductiveautomation.com/t/bringing-file-path-into-text-field/21248>\
**Category:** Ignition\
**Created:** [December 6, 2018, 12:07am UTC](https://forum.inductiveautomation.com/t/bringing-file-path-into-text-field/21248 "2018-12-06T00:07:19Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![paulm1](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paulm1/32/5900_2.png) [@paulm1](https://forum.inductiveautomation.com/u/paulm1)\
**Post date:** [December 6, 2018, 12:07am UTC](https://forum.inductiveautomation.com/t/bringing-file-path-into-text-field/21248/1 "2018-12-06T00:07:19Z")

</div>

By Using the Text Field Component - Scripting - mouseReleased - Script Editor  
path = system.file.openFile()  
I have been able to bring up a popup for selecting a file.  
 ![](https://cdck-file-uploads-us1.s3.dualstack.us-west-2.amazonaws.com/inductiveautomation/original/2X/9/984f4c7d352556bd103224ead7939f6ed23eb90f.png)

How do I move the selected file’s path into the same text Field’s Text Property?  
Properly formatted so the selected file (image) can be displayed in an Image component.

Example:  
 ![](https://cdck-file-uploads-us1.s3.dualstack.us-west-2.amazonaws.com/inductiveautomation/original/2X/a/a62dcb9e8ad575e0ed7377e029af2fc7ef26c2a8.png)

---

<div class="post-metadata">

**Author:** ![witman](https://avatars.discourse-cdn.com/v4/letter/w/d2c977/32.png) [@witman](https://forum.inductiveautomation.com/u/witman)\
**Post date:** [December 6, 2018, 12:30am UTC](https://forum.inductiveautomation.com/t/bringing-file-path-into-text-field/21248/2 "2018-12-06T00:30:23Z")

</div>

Add something like this to your script (edit to match your components):

```auto
event.source.parent.textField.text = path

```

Or are you already getting the path into the field but there’s a formatting issue? Share your code and details of what is not working as desired if you’d like a more detailed answer.

---

<div class="post-metadata">

**Author:** ![paulm1](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paulm1/32/5900_2.png) [@paulm1](https://forum.inductiveautomation.com/u/paulm1)\
**Post date:** [December 6, 2018, 12:44am UTC](https://forum.inductiveautomation.com/t/bringing-file-path-into-text-field/21248/3 "2018-12-06T00:44:01Z")

</div>

Works perfect! Thank you.  
I was close but oh so far from working.  
My final Script looks like this -

```auto
path = system.file.openFile()
if path != None:
    event.source.text = path

```

---

<div class="post-metadata">

**Author:** ![paulm1](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paulm1/32/5900_2.png) [@paulm1](https://forum.inductiveautomation.com/u/paulm1)\
**Post date:** [December 7, 2018, 12:02am UTC](https://forum.inductiveautomation.com/t/bringing-file-path-into-text-field/21248/4 "2018-12-07T00:02:01Z")

</div>

How would I change the script that opens the file popup so it will open an exact path?  
Right now I’m using the following.

```
path = system.file.openFile()

```

What if we want to bring the popup open to J:\Historian\pics?

---

<div class="post-metadata">

**Author:** ![witman](https://avatars.discourse-cdn.com/v4/letter/w/d2c977/32.png) [@witman](https://forum.inductiveautomation.com/u/witman)\
**Post date:** [December 7, 2018, 12:15am UTC](https://forum.inductiveautomation.com/t/bringing-file-path-into-text-field/21248/5 "2018-12-07T00:15:02Z")

</div>

Something like:

```auto
path = system.file.openFile(defaultLocation = 'J:\Historian\pics')

```

See [https://docs.inductiveautomation.com/display/DOC79/system.file.openFile](https://docs.inductiveautomation.com/display/DOC79/system.file.openFile). If you aren’t using all the parameters in a function like this, you just have to specify what you are using with the `parameterName =` syntax as in example above.

---

<div class="post-metadata">

**Author:** ![paulm1](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paulm1/32/5900_2.png) [@paulm1](https://forum.inductiveautomation.com/u/paulm1)\
**Post date:** [December 7, 2018, 12:29am UTC](https://forum.inductiveautomation.com/t/bringing-file-path-into-text-field/21248/6 "2018-12-07T00:29:03Z")

</div>

Thank You. The script below is working.

```
path = system.file.openFile(path = system.file.openFile('pdf', 'J:\FULLSAIL\Historian'))
if path != None:
event.source.text = path

```

Now I have one more question. What do I use in place of the ‘pdf’ to open All Files?  
I have tried several variations with no luck.

---

<div class="post-metadata">

**Author:** ![witman](https://avatars.discourse-cdn.com/v4/letter/w/d2c977/32.png) [@witman](https://forum.inductiveautomation.com/u/witman)\
**Post date:** [December 7, 2018, 12:32am UTC](https://forum.inductiveautomation.com/t/bringing-file-path-into-text-field/21248/7 "2018-12-07T00:32:04Z")

</div>

Does it work without error like this (not nested)?

```auto
path = system.file.openFile('pdf', 'J:\FULLSAIL\Historian')
if path != None:
	event.source.text = path

```

---

<div class="post-metadata">

**Author:** ![paulm1](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paulm1/32/5900_2.png) [@paulm1](https://forum.inductiveautomation.com/u/paulm1)\
**Post date:** [December 7, 2018, 12:43am UTC](https://forum.inductiveautomation.com/t/bringing-file-path-into-text-field/21248/8 "2018-12-07T00:43:49Z")

</div>

Yes. That solves that issue. Thanks

---

<div class="post-metadata">

**Author:** ![witman](https://avatars.discourse-cdn.com/v4/letter/w/d2c977/32.png) [@witman](https://forum.inductiveautomation.com/u/witman)\
**Post date:** [December 7, 2018, 12:45am UTC](https://forum.inductiveautomation.com/t/bringing-file-path-into-text-field/21248/9 "2018-12-07T00:45:29Z")

</div>

> [@paulm1](#):
>
> Now I have one more question. What do I use in place of the 'pdf' to open All Files?

Does this work?

```auto
path = system.file.openFile(defaultLocation = 'J:\FULLSAIL\Historian')
if path != None:
	event.source.text = path

```

---

<div class="post-metadata">

**Author:** ![paulm1](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paulm1/32/5900_2.png) [@paulm1](https://forum.inductiveautomation.com/u/paulm1)\
**Post date:** [December 7, 2018, 12:47am UTC](https://forum.inductiveautomation.com/t/bringing-file-path-into-text-field/21248/10 "2018-12-07T00:47:39Z")

</div>

Nope, Received this error.  
TypeError: openFile(): takes no keyword arguments

---

<div class="post-metadata">

**Author:** ![witman](https://avatars.discourse-cdn.com/v4/letter/w/d2c977/32.png) [@witman](https://forum.inductiveautomation.com/u/witman)\
**Post date:** [December 7, 2018, 1:02am UTC](https://forum.inductiveautomation.com/t/bringing-file-path-into-text-field/21248/11 "2018-12-07T01:02:52Z")

</div>

Okay, so `defaultLocation =` isn’t going to let us skip the file type. I’m not in a position to test at the moment, but a couple options I’d try if you haven’t already:

```auto
path = system.file.openFile( ,'J:\FULLSAIL\Historian')
if path != None:
	event.source.text = path

```

```auto
path = system.file.openFile('*','J:\FULLSAIL\Historian')
if path != None:
	event.source.text = path

```

---

<div class="post-metadata">

**Author:** ![paulm1](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paulm1/32/5900_2.png) [@paulm1](https://forum.inductiveautomation.com/u/paulm1)\
**Post date:** [December 7, 2018, 1:08am UTC](https://forum.inductiveautomation.com/t/bringing-file-path-into-text-field/21248/12 "2018-12-07T01:08:18Z")

</div>

I appreciate your help.

```
path = system.file.openFile( ,'J:\FULLSAIL\Historian')

```

Returns an error as soon as Apply is hit.

```
path = system.file.openFile('*','J:\FULLSAIL\Historian')

```

Opens the dialog box but is looking for files with the extension .\*  
Seems like what ever is entered into the first position is changed to .xxx

---

<div class="post-metadata">

**Author:** ![witman](https://avatars.discourse-cdn.com/v4/letter/w/d2c977/32.png) [@witman](https://forum.inductiveautomation.com/u/witman)\
**Post date:** [December 7, 2018, 1:15am UTC](https://forum.inductiveautomation.com/t/bringing-file-path-into-text-field/21248/13 "2018-12-07T01:15:05Z")

</div>

Could try just `''` (no space) in that first spot, but doesn’t sound promising. Sorry I’m out of ideas!

---

<div class="post-metadata">

**Author:** ![paulm1](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paulm1/32/5900_2.png) [@paulm1](https://forum.inductiveautomation.com/u/paulm1)\
**Post date:** [December 10, 2018, 6:26pm UTC](https://forum.inductiveautomation.com/t/bringing-file-path-into-text-field/21248/14 "2018-12-10T18:26:15Z")

</div>

I received an answer from Ignition Tech Support this morning. They said to use the following script.

```
path = system.file.openFile(None,'J:\FULLSAIL\Historian')

```

The term ‘None’ must have the first letter capitalized. i first tried ‘none’ and received an error msg.  
Tested and works exactly like I was hoping.  
Thanks to all for your help.

---

<div class="post-metadata">

**Author:** ![witman](https://avatars.discourse-cdn.com/v4/letter/w/d2c977/32.png) [@witman](https://forum.inductiveautomation.com/u/witman)\
**Post date:** [December 10, 2018, 7:15pm UTC](https://forum.inductiveautomation.com/t/bringing-file-path-into-text-field/21248/15 "2018-12-10T19:15:10Z")

</div>

That makes sense; thanks for posting the solution!
