How to save file to fix directory in Perspective


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


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.


Or use Vision instead of Perspective. :man_shrugging:


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?

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

See @Transistor's response.

You must use 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.


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

Where do you want this fixed directory to be?

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).


You have a dilemma, then, because Perspective can only use 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.