# How to save the uploaded file in default image folder (/system/images/)?

**URL:** <https://forum.inductiveautomation.com/t/how-to-save-the-uploaded-file-in-default-image-folder-system-images/32771>\
**Category:** General Discussion\
**Tags:** perspective\
**Created:** [March 3, 2020, 3:47pm UTC](https://forum.inductiveautomation.com/t/how-to-save-the-uploaded-file-in-default-image-folder-system-images/32771 "2020-03-03T15:47:48Z")\
**Posts on this page:** 13\
**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 3, 2020, 3:47pm UTC](https://forum.inductiveautomation.com/t/how-to-save-the-uploaded-file-in-default-image-folder-system-images/32771/1 "2020-03-03T15:47:48Z")

</div>

I am using file upload component to upload file and i want to save uploaded file on default image folder (/system/images/). I wrote the following code on onFileReceived event in file upload component:  
upload\_path = ‘/system/images/’  
system.util.getLogger(‘FILEUPLOAD’).info(‘Uploading: ‘{0}’ to directory ‘{1}’’.format(event.file.name, upload\_path))  
event.file.copyTo(upload\_path + event.file.name)

 ![cc](https://us1.discourse-cdn.com/inductiveautomation/original/2X/a/aeb50f5d966266144438519a99a3199f139a7ed5.png)

Thank you

---

<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:** [March 3, 2020, 4:03pm UTC](https://forum.inductiveautomation.com/t/how-to-save-the-uploaded-file-in-default-image-folder-system-images/32771/2 "2020-03-03T16:03:29Z")

</div>

This won’t work the way you’re expecting it to. The `/system/images/` route handler isn’t attached to an actual folder in the gateway install directory - it’s handled entirely in code, and retrieves images from the internal database. If you want to manually upload images, you’ll need to get a reference to the `ImageManager` on the gateway and call `insertImage` manually, filling in all the appropriate fields:  
[`com.inductiveautomation.ignition.gateway.images.ImageManager#insertImage`](http://files.inductiveautomation.com/sdk/javadoc/ignition79/795/com/inductiveautomation/ignition/gateway/images/ImageManager.html#insertImage-java.lang.String-java.lang.String-com.inductiveautomation.ignition.gateway.images.ImageFormat-java.lang.String-byte:A-int-int-int-). Actually doing so is unsupported, so you’re entirely on your own to figure out the details. Some searching on the forum should tell you how to get the `GatewayContext` class, from which you can `getImageManager`.

---

<div class="post-metadata">

**Author:** ![cmallonee](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmallonee/32/6416_2.png) [@cmallonee](https://forum.inductiveautomation.com/u/cmallonee)\
**Post date:** [March 3, 2020, 4:05pm UTC](https://forum.inductiveautomation.com/t/how-to-save-the-uploaded-file-in-default-image-folder-system-images/32771/3 "2020-03-03T16:05:19Z")

</div>

Or you could use this other "unsupported" avenue:

> [@File Upload Perspective](http://forum.inductiveautomation.com/t/file-upload-perspective/25797/2):
>
> upload\_path = 'webserver/webapps/main/' system.util.getLogger('FILEUPLOAD').info('Uploading: \'{0}\' to directory \'{1}\''.format(event.file.name, upload\_path)) event.file.copyTo(upload\_path + event.file.name) will place a file directly into the Inductive Automation\ignition\webserver\webapps\main directory of your Gateway. Assuming you upload a file to that destination, you can then locate that file (in the same script) with system.file.fileExists(upload\_path + event.file.name) If you were …

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [March 3, 2020, 4:52pm UTC](https://forum.inductiveautomation.com/t/how-to-save-the-uploaded-file-in-default-image-folder-system-images/32771/4 "2020-03-03T16:52:36Z")

</div>

If I recall correctly, files placed in /webapps/main are only noticed on gateway restart, not dynamically…

---

<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 3, 2020, 4:52pm UTC](https://forum.inductiveautomation.com/t/how-to-save-the-uploaded-file-in-default-image-folder-system-images/32771/5 "2020-03-03T16:52:59Z")

</div>

Thank you so much it worked!  
Is there any way that I can reduce the uploaded image file size?  
I wrote something as follows which it seems not working:

upload\_path = ‘webserver/webapps/main/’  
system.util.getLogger(‘FILEUPLOAD’).info(‘Uploading: ‘{0}’ to directory ‘{1}’’.format(event.file.name, upload\_path))  
event.file.copyTo(upload\_path + event.file.name)

```
import cv2

img=cv2.imread(upload_path + event.file.name)

scale_percent=0.50
width=int(img.shape[1]*scale_percent)
height=int(img.shape[0]*scale_percent)
dimension=(width,height)

resized=cv2.resize(img,dimension,interpolation=cv2.INTER_AREA)

print(resized.shape)
cv2.imshow('output',resized)
cv2.imwrite('resized_2.jpg',resized)![w|690x367](upload://tWcZkroKiMnNw0RzWRZeyPXTXEi.png)
```

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [March 3, 2020, 4:57pm UTC](https://forum.inductiveautomation.com/t/how-to-save-the-uploaded-file-in-default-image-folder-system-images/32771/6 "2020-03-03T16:57:28Z")

</div>

> [@ptchanchal](#):
>
> import cv2

Uh, that's OpenCV, which needs native code support. They python bindings for OpenCV do _ **not** _ work in jython.

---

<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 3, 2020, 4:59pm UTC](https://forum.inductiveautomation.com/t/how-to-save-the-uploaded-file-in-default-image-folder-system-images/32771/7 "2020-03-03T16:59:17Z")

</div>

Is there any other way then that I can reduce the uploaded file size?

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [March 3, 2020, 5:03pm UTC](https://forum.inductiveautomation.com/t/how-to-save-the-uploaded-file-in-default-image-folder-system-images/32771/8 "2020-03-03T17:03:32Z")

</div>

Try the corresponding functionality in Java’s own [ImageIO](https://docs.oracle.com/javase/8/docs/api/javax/imageio/ImageIO.html) library.

---

<div class="post-metadata">

**Author:** ![jsalas](https://avatars.discourse-cdn.com/v4/letter/j/74df32/32.png) [@jsalas](https://forum.inductiveautomation.com/u/jsalas)\
**Post date:** [July 12, 2021, 11:13pm UTC](https://forum.inductiveautomation.com/t/how-to-save-the-uploaded-file-in-default-image-folder-system-images/32771/9 "2021-07-12T23:13:48Z")

</div>

Why is this considered ‘unsupported’? Are there any drawbacks to this approach, i.e. using too many of the Gateway’s resources?

---

<div class="post-metadata">

**Author:** ![cmallonee](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmallonee/32/6416_2.png) [@cmallonee](https://forum.inductiveautomation.com/u/cmallonee)\
**Post date:** [July 13, 2021, 1:13am UTC](https://forum.inductiveautomation.com/t/how-to-save-the-uploaded-file-in-default-image-folder-system-images/32771/10 "2021-07-13T01:13:41Z")

</div>

I don’t think files placed there are placed into any recovery backup. Also, most of the time when you want to use a file after it’s been uploaded (like a profile picture for example), you would want to serve that file as a resource through the WebDev module, which is not what this route is doing; this route id just directly placing a file into the file system.

---

<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:** [July 13, 2021, 3:39pm UTC](https://forum.inductiveautomation.com/t/how-to-save-the-uploaded-file-in-default-image-folder-system-images/32771/11 "2021-07-13T15:39:06Z")

</div>

> [@jsalas](#):
>
> Why is this considered ‘unsupported’? Are there any drawbacks to this approach, i.e. using too many of the Gateway’s resources?

It's unsupported, because if you use it and something goes wrong, you're on your own. We never explicitly set out to make the webserver/webapps/main path automatically hosted - it's just a coincidence of the way we set up Jetty. Some future upgrade of Jetty may make that work differently, or we could explicitly gate the feature behind a config flag, or something.

In practice, because it's such an open secret, we'd probably take pains to prevent anything from breaking it upon such a hypothetical Jetty upgrade, but the reason we claim it's 'unsupported' is because you're basically relying on undefined Jetty behavior, not anything coded into Ignition deliberately.

---

<div class="post-metadata">

**Author:** ![Tamilvanan\_S](https://avatars.discourse-cdn.com/v4/letter/t/ecae2f/32.png) [@Tamilvanan\_S](https://forum.inductiveautomation.com/u/Tamilvanan_S)\
**Post date:** [January 29, 2024, 10:04am UTC](https://forum.inductiveautomation.com/t/how-to-save-the-uploaded-file-in-default-image-folder-system-images/32771/12 "2024-01-29T10:04:10Z")

</div>

Hi, I tried this one i got Access is denied error.  
I am using File upload component. I need file path. kindly help me how to take file path

---

<div class="post-metadata">

**Author:** ![cmallonee](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmallonee/32/6416_2.png) [@cmallonee](https://forum.inductiveautomation.com/u/cmallonee)\
**Post date:** [January 29, 2024, 3:35pm UTC](https://forum.inductiveautomation.com/t/how-to-save-the-uploaded-file-in-default-image-folder-system-images/32771/13 "2024-01-29T15:35:39Z")

</div>

> [@Tamilvanan\_S](#):
>
> i got Access is denied error.

I would need to see the actual error to have a better idea of what you're encountering. Please provide the stacktrace, relevant log line, or a screenshot of the error.
