Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

251
Views
Write and save file with plain vanilla JavaScript

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

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

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.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!