Is there really no way to save data into a file without nodeJS or without using a download link action of the browser? I want to replace my function that saves data to the localStorage and want to save some user input into a single text file within the project folder.
I have already a file created. How can I write into it and how can I save it?
var loc = window.location.pathname;
var dir = loc.substring(0, loc.lastIndexOf('/'));
var file = new File(["foo"], dir + "/test.txt", {
type: "text/plain",
});
var str = "My string of text";
Thanks for any idea :)
I think the answer is no. To my understanding the whole point of JavaScript was that it runs within the browser. For security reasons the browser is meant not to have direct code access to the host system, so JavaScript has this limitation by design.
The point of NodeJS was to allow JavaScript code to run on a host computer and expands on the library of functions provided with JS to include things like file manipulation.