browser Javascript write to file

The links below shows how to write to file, it seems to be working for desktop only
https://forums.rpgmakerweb.com/index.php?threads/read-write-to-external-txt-file.81074/
http://endlessillusoft.com/rpgmakermv-node-js-part-1-reading-and-writing-files/

how do you change the code so it would work in browser too?
Any help is appreciated Thanks in advance
https://ourcodeworld.com/articles/r...th-javascript-in-the-browser-without-a-server

As for uploading files in case you need it, that's more complicated as you need to use some php server-side code as well.
https://www.taniarascia.com/how-to-upload-files-to-a-server-with-plain-javascript-and-php/
If I'm reading it correctly, that first link just saves the file to the Downloads folder?
I don't think there is a way for a browser to save a file to a specific part of your computer, that's probably for the best.
@Aloe Guvner Depends on browser settings. You can, as an user, set a folder a file would be downloaded into. But the server cannot force a download to a specific folder as the server has no power over the browser.

Original thread: https://forums.rpgmakerweb.com/threads/browser-javascript-write-to-file.107192/