Inserting image into database in Perspective

We tried inserting the image into database from Ignition Perspective using the code given below and we get the error as in the screen shot.

path = system.file.openFile()
if path != None:
bytes = system.file.readFileAsBytes(path)
system.db.runPrepUpdate(“INSERT INTO SOP_Master (Defect_Image) VALUES (?)”, [bytes])

Please advise.

system.file.openFile() is only scoped for vision client. (documentation)

I don’t think you can use it at the gateway scope which takes it off the table in perspective.

You have to use the File Upload component. Web browsers don’t allow pages to open unsolicited file upload prompts - you can only prompt a user for a file after some user interaction.

It is working .Thanks for your support.