I'm making a form on JavaScript and I want to save all of the users entered variables to either a .txt file or a new webpage with the variables pre entered in the inputs. I understand the JavaScript cant manipulate the users machine but can it manipulate the servers files(create new files) If it can how would one save variables onto a new file in a way that could then be imported back into the website? Any input is appreciated :) Aaron~
2 Answers
JavaScript running in the browser can make HTTP requests to the server (generally by using the XMLHTTPRequest object).
It can't write arbitrary files to it (if it could, then any client could, and anyone could deface any website)
You need some form of server side process running on the server that can interpret an HTTP request as meaning "Write something to a file" (although, in most cases, you would write to a database and generate the file on request from the data there).
You could write the server side process in JavaScript if you have a suitable server side environment (such as Node.js).