0

I have created file using blob. How can I write or append data into the same file, which I've created at a local path?

let blob = new Blob("Helloworld",{ type: 'text/plain' });
saveAs(blob, "Download\new.txt")

What should I write in the code for appending new data to new.txt

Pawel Veselov
  • 3,808
  • 6
  • 42
  • 59
ashish
  • 1
  • 1

1 Answers1

0

You cannot write to the filesystem directly from inside the browser. The best you can do is to create a button and when the button is clicked, it opens a file picker letting the user to choose where to save the file. Here is another post showing how to do it.


Alternatively, you can use the File and Directory Entries API on supported browsers to save file directly. This api standard is still a draft so use it with caution.

Alvin Leung
  • 468
  • 3
  • 9