# Inserting image into database in Perspective

**URL:** <https://forum.inductiveautomation.com/t/inserting-image-into-database-in-perspective/37920>\
**Category:** Ignition\
**Created:** [August 19, 2020, 5:24pm UTC](https://forum.inductiveautomation.com/t/inserting-image-into-database-in-perspective/37920 "2020-08-19T17:24:33Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![rajeshbabu](https://avatars.discourse-cdn.com/v4/letter/r/35a633/32.png) [@rajeshbabu](https://forum.inductiveautomation.com/u/rajeshbabu)\
**Post date:** [August 19, 2020, 5:24pm UTC](https://forum.inductiveautomation.com/t/inserting-image-into-database-in-perspective/37920/1 "2020-08-19T17:24:33Z")

</div>

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])

 ![DB Image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/8/e/8edc5241addac475a5126419648be53a3957a37f.png)

Please advise.

---

<div class="post-metadata">

**Author:** ![zacht](https://avatars.discourse-cdn.com/v4/letter/z/ea5d25/32.png) [@zacht](https://forum.inductiveautomation.com/u/zacht)\
**Post date:** [August 19, 2020, 5:32pm UTC](https://forum.inductiveautomation.com/t/inserting-image-into-database-in-perspective/37920/2 "2020-08-19T17:32:55Z")

</div>

system.file.openFile() is only scoped for vision client. ([documentation](https://docs.inductiveautomation.com/display/DOC80/system.file.openFile))

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

---

<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:** [August 19, 2020, 5:44pm UTC](https://forum.inductiveautomation.com/t/inserting-image-into-database-in-perspective/37920/3 "2020-08-19T17:44:47Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![rajeshbabu](https://avatars.discourse-cdn.com/v4/letter/r/35a633/32.png) [@rajeshbabu](https://forum.inductiveautomation.com/u/rajeshbabu)\
**Post date:** [August 25, 2020, 4:54pm UTC](https://forum.inductiveautomation.com/t/inserting-image-into-database-in-perspective/37920/4 "2020-08-25T16:54:42Z")

</div>

It is working .Thanks for your support.
