# How to save file to fix directory in Perspective

**URL:** <https://forum.inductiveautomation.com/t/how-to-save-file-to-fix-directory-in-perspective/90263>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [May 11, 2024, 11:28am UTC](https://forum.inductiveautomation.com/t/how-to-save-file-to-fix-directory-in-perspective/90263 "2024-05-11T11:28:02Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Anita.Shinde](https://avatars.discourse-cdn.com/v4/letter/a/c2a13f/32.png) [@Anita.Shinde](https://forum.inductiveautomation.com/u/Anita.Shinde)\
**Post date:** [May 11, 2024, 11:28am UTC](https://forum.inductiveautomation.com/t/how-to-save-file-to-fix-directory-in-perspective/90263/1 "2024-05-11T11:28:02Z")

</div>

Hi,

I want to save json file to one fix directory, dont want the option to select directory.  
How can I do that?

Thanks

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [May 11, 2024, 12:11pm UTC](https://forum.inductiveautomation.com/t/how-to-save-file-to-fix-directory-in-perspective/90263/2 "2024-05-11T12:11:20Z")

</div>

You can't.  
File download directory is determined by the browser settings. It can usually be set to a default folder like "Download" in Windows or "Always ask".  
For cyber-security reasons a website cannot specify the destination folder.

---

<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:** [May 11, 2024, 12:15pm UTC](https://forum.inductiveautomation.com/t/how-to-save-file-to-fix-directory-in-perspective/90263/3 "2024-05-11T12:15:20Z")

</div>

Or use Vision instead of Perspective. 🤷‍♂️

---

<div class="post-metadata">

**Author:** ![Anita.Shinde](https://avatars.discourse-cdn.com/v4/letter/a/c2a13f/32.png) [@Anita.Shinde](https://forum.inductiveautomation.com/u/Anita.Shinde)\
**Post date:** [May 16, 2024, 2:17pm UTC](https://forum.inductiveautomation.com/t/how-to-save-file-to-fix-directory-in-perspective/90263/4 "2024-05-16T14:17:55Z")

</div>

Hi,

I am using this code to save the file.  
I created 2 function in project library save\_file and write\_file.  
I have 2 buttons I am calling save\_file() from 1st button and calling write\_file() from another function.  
the issue is, I am able to call save\_file and popup gets open but from second button write\_file() is not calling.  
is there any issue in script, As both functions are in same lib still one is calling and another is not, whats the issue here?  
Can anyone please help?

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/c/3/c3c11f963eba6e13c3e8e222c943324f63379699.png)

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [May 16, 2024, 2:30pm UTC](https://forum.inductiveautomation.com/t/how-to-save-file-to-fix-directory-in-perspective/90263/5 "2024-05-16T14:30:41Z")

</div>

> [@Anita.Shinde](#):
>
> whats the issue here?

The issue is you are trying to do something that you can not do.

See @Transistor's response.

You must use `system.perspective.download()` to download data to the client machine. The programmer can do nothing more than suggest to the user where the data should be downloaded to.

This code as written, if it did work, would save the file to the Gateway, which I don't think is what you want.

---

<div class="post-metadata">

**Author:** ![Anita.Shinde](https://avatars.discourse-cdn.com/v4/letter/a/c2a13f/32.png) [@Anita.Shinde](https://forum.inductiveautomation.com/u/Anita.Shinde)\
**Post date:** [May 16, 2024, 2:34pm UTC](https://forum.inductiveautomation.com/t/how-to-save-file-to-fix-directory-in-perspective/90263/6 "2024-05-16T14:34:23Z")

</div>

No, I cant use perspective.download, beause I want to save file in fixed directory

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [May 16, 2024, 2:37pm UTC](https://forum.inductiveautomation.com/t/how-to-save-file-to-fix-directory-in-perspective/90263/7 "2024-05-16T14:37:54Z")

</div>

> [@Anita.Shinde](#):
>
> I want to save file in fixed directory

Where do you want this fixed directory to be?

---

<div class="post-metadata">

**Author:** ![michael.flagler](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/michael.flagler/32/26272_2.png) [@michael.flagler](https://forum.inductiveautomation.com/u/michael.flagler)\
**Post date:** [May 16, 2024, 2:42pm UTC](https://forum.inductiveautomation.com/t/how-to-save-file-to-fix-directory-in-perspective/90263/8 "2024-05-16T14:42:35Z")

</div>

The only fixed directories you can download to are those directly accessible by the gateway.

Keep in mind, Perspective is a web based client, so if this capability were possible, hackers would have a field day automatically writing viruses to unsuspecting users when they visit a compromised website. Due to security, doing what you're asking on a client's computer isn't possible. The alternative is to set up the browser on the client PC to always download to a fixed folder and not prompt the user for a folder. By default, this is the Download folder in the user's profile, but can usually be changed (but not by the web app/perspective).

---

<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:** [May 16, 2024, 3:06pm UTC](https://forum.inductiveautomation.com/t/how-to-save-file-to-fix-directory-in-perspective/90263/9 "2024-05-16T15:06:57Z")

</div>

> [@Anita.Shinde](#):
>
> I cant use perspective.download

You have a dilemma, then, because Perspective can **only** use `system.perspective.download()` to deliver files to users machines. And browsers **do not permit** websites to tell them what to do with the download.

If you **must** load files into the client machine automatically, your **only** choice is to redo your application in Vision. Perspective **cannot** do this and will likely **never** will be able to do this. Because this behavior (in browsers) is indistinguishable from malware.
