system.file.openFile in perspective

I work with Ignition 8.1.
I’m trying to import an xml file with the function system.file.openFile() in perspective.
I use this function in the script editor and I call it under a button on the action performed event :

But when I click on my button I’ve got this issue :

I took the code directly from the sepasoft help website.
When I used it in the script console, I don’t have any issues.
Thank you :slight_smile:

I’m pretty sure system.file.openFile() is a Vision client scoped function, so I wouldn’t expect it to work in Perspective. You could theoretically modify your importMaterial() function to accept a path argument where you pass in the file path to what you are looking for on the gateway machine use that into system.file.readFileAsString() instead.

Edit: Alternatively, if you needed access to a file that is not already hosted on the gateway machine, you could use the Perspective file upload component:

That component has an event.file.getString() event handler that might also get you what you’re looking for.


The file upload component is not just the way to go, it’s the only way to go. For security reasons, browsers don’t allow javascript to open things like file pickers without active user input.

1 Like

hi valentin.guichard, can u tell how you have done this.

i tried using file upload, but i cannnot able to acheive.

To use the file you pass to thé file upload, you need to go on the object event and write your script in “onFileReceive” event. You can get more info about here: Perspective - File Upload - Ignition User Manual 8.0 - Ignition Documentation