# Upload component gets file Received Script triggered twice

**URL:** <https://forum.inductiveautomation.com/t/upload-component-gets-file-received-script-triggered-twice/97653>\
**Category:** Ignition\
**Tags:** ignition81, python, scripting, perspective\
**Created:** [October 23, 2024, 9:18am UTC](https://forum.inductiveautomation.com/t/upload-component-gets-file-received-script-triggered-twice/97653 "2024-10-23T09:18:54Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Amitkumar\_Ravat1](https://avatars.discourse-cdn.com/v4/letter/a/b5a626/32.png) [@Amitkumar\_Ravat1](https://forum.inductiveautomation.com/u/Amitkumar_Ravat1)\
**Post date:** [October 23, 2024, 9:18am UTC](https://forum.inductiveautomation.com/t/upload-component-gets-file-received-script-triggered-twice/97653/1 "2024-10-23T09:18:54Z")

</div>

I have perspective view where i am uploading  
a excel file for that onfilereceived event i have script to parse the excel but the onfilereceived is getting triggered twice and sometime once it is getting triggered how do i restrict this from getting triggered twice.  
Thanks for the help

---

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [October 23, 2024, 12:13pm UTC](https://forum.inductiveautomation.com/t/upload-component-gets-file-received-script-triggered-twice/97653/2 "2024-10-23T12:13:23Z")

</div>

Are you sure it's getting triggered twice?  
I added a print statement to the `onFileReceived` event and it only fired once when I uploaded a file

```python
system.perspective.print(event)

```

---

<div class="post-metadata">

**Author:** ![Ryan\_Deardorff](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryan_deardorff/32/63815_2.png) [@Ryan\_Deardorff](https://forum.inductiveautomation.com/u/Ryan_Deardorff)\
**Post date:** [October 23, 2024, 1:44pm UTC](https://forum.inductiveautomation.com/t/upload-component-gets-file-received-script-triggered-twice/97653/3 "2024-10-23T13:44:23Z")

</div>

I ran into that issue myself a while back, and came up with this workaround:

```python
def runAction(self, event):
	import java.lang.Exception
	from threading import Timer
	
	# Fixes a bug in Ignition that causes this event to fire twice in a row...
	def setOkayToUpload(self):
		self.custom.okayToUpload = True
	
	if self.custom.okayToUpload:
		self.custom.okayToUpload = False
		...(process upload)...
		Timer(0.5, setOkayToUpload, [self]).start()

```

---

<div class="post-metadata">

**Author:** ![josborn](https://avatars.discourse-cdn.com/v4/letter/j/4bbf92/32.png) [@josborn](https://forum.inductiveautomation.com/u/josborn)\
**Post date:** [October 23, 2024, 4:01pm UTC](https://forum.inductiveautomation.com/t/upload-component-gets-file-received-script-triggered-twice/97653/4 "2024-10-23T16:01:28Z")

</div>

There was a bug where small files would trigger twice when uploaded.

> [@Nightly 8.1 Changelogs - 2023](https://forum.inductiveautomation.com/t/nightly-8-1-changelogs-2023/68524/176):
>
> Nightly Changelog: 8.1.36-SNAPSHOT-b20231205 Perspective Perspective IGN-8219: Perspective: File Upload Component’s onFileReceived event unexpectedly fires twice when a small file is uploaded Fixed book keeping mistake related to the File Upload component and small file uploads.

I used this work around as I am not quite ready to update:

> [@\[IGN-8219\] Perspective File Upload onFileReceived being called twice](https://forum.inductiveautomation.com/t/ign-8219-perspective-file-upload-onfilereceived-being-called-twice/32472/5):
>
> I easily get around it by modifying the code to check the filename to ensure we don't do the same file twice in a row: def runAction(self, event): # Grab the file name and data filename = event.file.name filedata = event.file.getString() # Check if this file has just been uploaded - to stop a double import (potential platform/browser bug) if filename \<\> self.custom.filename: # Call the import function on the table self.parent.parent.getChild("Table").importCSV(filename, filedata) …

---

<div class="post-metadata">

**Author:** ![Amitkumar\_Ravat1](https://avatars.discourse-cdn.com/v4/letter/a/b5a626/32.png) [@Amitkumar\_Ravat1](https://forum.inductiveautomation.com/u/Amitkumar_Ravat1)\
**Post date:** [October 23, 2024, 4:37pm UTC](https://forum.inductiveautomation.com/t/upload-component-gets-file-received-script-triggered-twice/97653/5 "2024-10-23T16:37:30Z")

</div>

Thanks for the help i will also try to do the same

---

<div class="post-metadata">

**Author:** ![Christian\_Mayne](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/christian_mayne/32/73325_2.png) [@Christian\_Mayne](https://forum.inductiveautomation.com/u/Christian_Mayne)\
**Post date:** [February 19, 2026, 9:22pm UTC](https://forum.inductiveautomation.com/t/upload-component-gets-file-received-script-triggered-twice/97653/7 "2026-02-19T21:22:01Z")

</div>

I thought I had encountered this bug in 8.3.3, see this other thread for my notes on it.

> [@\[IGN-8219\] Perspective File Upload onFileReceived being called twice](https://forum.inductiveautomation.com/t/ign-8219-perspective-file-upload-onfilereceived-being-called-twice/32472/16):
>
> As an update, I worked with @cmallonee , niether of us could replicate this issue. I originally had the issue from the context of the designer interface and was connected to the gateway via VPN and there may have been a substantial amount of latency between the session and the gateway.
