# How to save the uploaded image to database in perspective?

**URL:** <https://forum.inductiveautomation.com/t/how-to-save-the-uploaded-image-to-database-in-perspective/32813>\
**Category:** General Discussion\
**Tags:** perspective\
**Created:** [March 4, 2020, 9:41pm UTC](https://forum.inductiveautomation.com/t/how-to-save-the-uploaded-image-to-database-in-perspective/32813 "2020-03-04T21:41:28Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![ptchanchal](https://avatars.discourse-cdn.com/v4/letter/p/f9ae1b/32.png) [@ptchanchal](https://forum.inductiveautomation.com/u/ptchanchal)\
**Post date:** [March 4, 2020, 9:41pm UTC](https://forum.inductiveautomation.com/t/how-to-save-the-uploaded-image-to-database-in-perspective/32813/1 "2020-03-04T21:41:28Z")

</div>

I am using a file upload component in perspective to upload multiple images and I want to save those uploaded images to my database. How can I do that that?

Thank You

---

<div class="post-metadata">

**Author:** ![wking](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/wking/32/21823_2.png) [@wking](https://forum.inductiveautomation.com/u/wking)\
**Post date:** [March 5, 2020, 1:44am UTC](https://forum.inductiveautomation.com/t/how-to-save-the-uploaded-image-to-database-in-perspective/32813/2 "2020-03-05T01:44:57Z")

</div>

I would,

configure an onFileReceived event script and invoke event.file.getBytes() and send to DB as blob

---

<div class="post-metadata">

**Author:** ![ptchanchal](https://avatars.discourse-cdn.com/v4/letter/p/f9ae1b/32.png) [@ptchanchal](https://forum.inductiveautomation.com/u/ptchanchal)\
**Post date:** [March 6, 2020, 7:22pm UTC](https://forum.inductiveautomation.com/t/how-to-save-the-uploaded-image-to-database-in-perspective/32813/3 "2020-03-06T19:22:47Z")

</div>

It worked, thank you and now I am trying to retrieve the saved image from database and show it in image component in perspective. I tried different ways but none of them seems working.

---

<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 6, 2020, 7:56pm UTC](https://forum.inductiveautomation.com/t/how-to-save-the-uploaded-image-to-database-in-perspective/32813/4 "2020-03-06T19:56:29Z")

</div>

> [@View Images from Database](http://forum.inductiveautomation.com/t/view-images-from-database/22626/4):
>
> If you’re asking for how to do this in Perspective: Currently, you would probably have to do it using a webdev script, that could either return the image directly or a correctly formatted base64 string, which would then be able to be used by Perspective’s image component (I’m pretty sure). There are some ways that we could improve this experience, but the hard problem to deal with is the fact that the browser can’t directly access the database - so we need to deliver the images to it from the g…

---

<div class="post-metadata">

**Author:** ![ptchanchal](https://avatars.discourse-cdn.com/v4/letter/p/f9ae1b/32.png) [@ptchanchal](https://forum.inductiveautomation.com/u/ptchanchal)\
**Post date:** [March 6, 2020, 8:01pm UTC](https://forum.inductiveautomation.com/t/how-to-save-the-uploaded-image-to-database-in-perspective/32813/5 "2020-03-06T20:01:15Z")

</div>

I am new in ignition, I don’t know how to achieve that using webdev, if you could help me with that then it will be really helpful.

Thank you.

---

<div class="post-metadata">

**Author:** ![wking](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/wking/32/21823_2.png) [@wking](https://forum.inductiveautomation.com/u/wking)\
**Post date:** [March 6, 2020, 9:31pm UTC](https://forum.inductiveautomation.com/t/how-to-save-the-uploaded-image-to-database-in-perspective/32813/6 "2020-03-06T21:31:16Z")

</div>

What kind of DB are you using?

---

<div class="post-metadata">

**Author:** ![ptchanchal](https://avatars.discourse-cdn.com/v4/letter/p/f9ae1b/32.png) [@ptchanchal](https://forum.inductiveautomation.com/u/ptchanchal)\
**Post date:** [March 6, 2020, 9:41pm UTC](https://forum.inductiveautomation.com/t/how-to-save-the-uploaded-image-to-database-in-perspective/32813/7 "2020-03-06T21:41:14Z")

</div>

MySQL

---

<div class="post-metadata">

**Author:** ![wking](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/wking/32/21823_2.png) [@wking](https://forum.inductiveautomation.com/u/wking)\
**Post date:** [March 6, 2020, 10:13pm UTC](https://forum.inductiveautomation.com/t/how-to-save-the-uploaded-image-to-database-in-perspective/32813/8 "2020-03-06T22:13:55Z")

</div>

If they’re small. You would query them out as base 64. with TO\_BASE64(col)

In Jordan’s post, it goes over that. 👆

You could also store them straight to the directory. Something like

```auto
	upload_path = 'webserver/webapps/main/'
	event.file.copyTo(upload_path + event.file.name)

```
