# File Upload Perspective

**URL:** <https://forum.inductiveautomation.com/t/file-upload-perspective/25797>\
**Category:** Ignition\
**Created:** [June 13, 2019, 2:07pm UTC](https://forum.inductiveautomation.com/t/file-upload-perspective/25797 "2019-06-13T14:07:15Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![souxifou](https://avatars.discourse-cdn.com/v4/letter/s/bbce88/32.png) [@souxifou](https://forum.inductiveautomation.com/u/souxifou)\
**Post date:** [June 13, 2019, 2:07pm UTC](https://forum.inductiveautomation.com/t/file-upload-perspective/25797/1 "2019-06-13T14:07:15Z")

</div>

Hi everyone,

I need some helps with the file upload component, even with the doc i don’t understand how it work.

I need this component for uploading a picture from my tablet to send it to some one else.

Somebody can explain me how this component work ?

Actualy I tried to use the " onFileReceived " event with event.file.copyto but I’m stuck.

---

<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:** [June 13, 2019, 3:02pm UTC](https://forum.inductiveautomation.com/t/file-upload-perspective/25797/2 "2019-06-13T15:02:08Z")

</div>

```auto
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

```auto
system.file.fileExists(upload_path + event.file.name)

```

If you were to upload an image with a file name of “filename.jpeg”, for example, then you would then point to that file in an Image component with `/filename.jpeg`.

---

<div class="post-metadata">

**Author:** ![souxifou](https://avatars.discourse-cdn.com/v4/letter/s/bbce88/32.png) [@souxifou](https://forum.inductiveautomation.com/u/souxifou)\
**Post date:** [June 14, 2019, 7:19am UTC](https://forum.inductiveautomation.com/t/file-upload-perspective/25797/3 "2019-06-14T07:19:23Z")

</div>

Thanks you a lot !

There is a component or a method which allow me to take a picture from my tablet camera (by the way is not an android tablet) ?

---

<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:** [June 14, 2019, 2:22pm UTC](https://forum.inductiveautomation.com/t/file-upload-perspective/25797/4 "2019-06-14T14:22:37Z")

</div>

We do not currently have any way for Perspective to take a picture with a mobile device (outside of scanning a barcode, which does not actually save a file to your device). A “Picture” action is something we’re considering in later versions, but it’s not even in a planning stage yet.

---

<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:** [June 14, 2019, 3:17pm UTC](https://forum.inductiveautomation.com/t/file-upload-perspective/25797/5 "2019-06-14T15:17:25Z")

</div>

Although, at least some browsers (mobile Safari in particular I know does this) allow you to directly take a picture when prompted to upload a file. It’s up to your device and browser whether to prompt for this, so it’s worth trying different browsers and looking into device settings.

---

<div class="post-metadata">

**Author:** ![souxifou](https://avatars.discourse-cdn.com/v4/letter/s/bbce88/32.png) [@souxifou](https://forum.inductiveautomation.com/u/souxifou)\
**Post date:** [June 17, 2019, 12:01pm UTC](https://forum.inductiveautomation.com/t/file-upload-perspective/25797/6 "2019-06-17T12:01:04Z")

</div>

Thanks, but i will look if with my windows 10 tablet i can have this.

---

<div class="post-metadata">

**Author:** ![AJBerera](https://avatars.discourse-cdn.com/v4/letter/a/9fc29f/32.png) [@AJBerera](https://forum.inductiveautomation.com/u/AJBerera)\
**Post date:** [December 9, 2019, 3:50pm UTC](https://forum.inductiveautomation.com/t/file-upload-perspective/25797/7 "2019-12-09T15:50:16Z")

</div>

Any updates/ plans to make this a feature in the app?

---

<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:** [December 9, 2019, 11:32pm UTC](https://forum.inductiveautomation.com/t/file-upload-perspective/25797/8 "2019-12-09T23:32:13Z")

</div>

To make what a feature in the app?

---

<div class="post-metadata">

**Author:** ![victordcq](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@victordcq](https://forum.inductiveautomation.com/u/victordcq)\
**Post date:** [September 13, 2021, 2:39pm UTC](https://forum.inductiveautomation.com/t/file-upload-perspective/25797/10 "2021-09-13T14:39:15Z")

</div>

@cmallonee  
the folders/directories in webserver\webapps\main seems to be forbidden to acces in the browser (error 403) i can acces the images inside it, but i would also like to acces the whole folder itself  
is there somewhere where i can allow it? (some htacces config or something?)

in the webserver/webdefault servlet file the dirAllowed is already true so not sure where else it could be

edit:  
ah nvm i found it  
`webserver\webapps\main\WEB-INF\web` here it stood on false

---

<div class="post-metadata">

**Author:** ![nader.chinichian](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nader.chinichian/32/9261_2.png) [@nader.chinichian](https://forum.inductiveautomation.com/u/nader.chinichian)\
**Post date:** [February 10, 2022, 3:50pm UTC](https://forum.inductiveautomation.com/t/file-upload-perspective/25797/11 "2022-02-10T15:50:52Z")

</div>

Hi @cmallonee  
I use your code and it work perfectly the only problem is the image component cache the old image and if I change the image it show the old one always.  
It seems perspective cache every thing. Is there any way to disable caching for image component?

---

<div class="post-metadata">

**Author:** ![jacque\_trahan](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jacque_trahan/32/58886_2.png) [@jacque\_trahan](https://forum.inductiveautomation.com/u/jacque_trahan)\
**Post date:** [February 22, 2024, 8:03pm UTC](https://forum.inductiveautomation.com/t/file-upload-perspective/25797/12 "2024-02-22T20:03:02Z")

</div>

I am curious if there is a way to get the file path from this component. This way It would be easier for the users, and it would be less changes to code I already have set up.

Currently I am storing the contents of the file in a custom tag property on the main view, then I can read it in that way. But I do not like having to import two libraries if I can help it.

```auto
def runAction(self, event):
	import csv
	import io
	
	fileContents = self.view.custom.csvFileContents
	
	csvFile = io.StringIO(fileContents)
	csvReader = csv.DictReader(csvFile, delimiter = ',')
	for colHeader in csvReader:
	    system.perspective.print(colHeader['UDTDefPath'])

```

**Edit:**  
I know I can get it from the gateway but I am not trying to save the files there. Sorry should have clarified this.

---

<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:** [February 22, 2024, 8:22pm UTC](https://forum.inductiveautomation.com/t/file-upload-perspective/25797/13 "2024-02-22T20:22:05Z")

</div>

> [@jacque\_trahan](#):
>
> to get the file path from this component

What file path? From the client browser? That would be a security hole in the browser.

If you mean the folder path in the gateway, then it is always a temporary folder, and the file name used in that folder is not under your control. If you don't handle the file in the uploaded event with the supported accessors, the content will be discarded.

It is wise to put the file **somewhere** other than gateway RAM if uploads are expected to be large. (Perspective properties all use gateway RAM.)

---

<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:** [February 22, 2024, 8:28pm UTC](https://forum.inductiveautomation.com/t/file-upload-perspective/25797/14 "2024-02-22T20:28:09Z")

</div>

Expect a better first party solution for this in 8.3.

---

<div class="post-metadata">

**Author:** ![jacque\_trahan](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jacque_trahan/32/58886_2.png) [@jacque\_trahan](https://forum.inductiveautomation.com/u/jacque_trahan)\
**Post date:** [February 22, 2024, 8:32pm UTC](https://forum.inductiveautomation.com/t/file-upload-perspective/25797/15 "2024-02-22T20:32:54Z")

</div>

Oh that's cool!

As of now when I/others need to make an edit using a CSV file I made a text component and just read the file path from that component into the csv python with open() aspect. I just hold shift on the file then right click and select **copy as path** to get:

> "C:\temp\mods2.csv"

pic example:  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/7/8/78ea09ed1ac52a6283eb6092c4a2c102b5d321da.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:** [February 22, 2024, 8:54pm UTC](https://forum.inductiveautomation.com/t/file-upload-perspective/25797/16 "2024-02-22T20:54:00Z")

</div>

> [@paul-griffith](#):
>
> solution for this in 8.3.

For the browser side source path?

---

<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:** [February 22, 2024, 8:58pm UTC](https://forum.inductiveautomation.com/t/file-upload-perspective/25797/17 "2024-02-22T20:58:22Z")

</div>

For the use case of "I want to store files uploaded via Perspective in a well known, configurable location, with minimal scripting required".

---

<div class="post-metadata">

**Author:** ![Steve\_Laubach](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/steve_laubach/32/60900_2.png) [@Steve\_Laubach](https://forum.inductiveautomation.com/u/Steve_Laubach)\
**Post date:** [February 22, 2024, 9:14pm UTC](https://forum.inductiveautomation.com/t/file-upload-perspective/25797/18 "2024-02-22T21:14:54Z")

</div>

I'm feeling the hype for 8.3.
