Anderson Green
Anderson Green

Reputation: 31800

Modify an existing file using HTML5 and Javascript

I'm trying to write a simple client-side text editor using HTML5 and Javascript. Is it possible to overwrite the contents of an existing text file using HTML5? I know that the HTML File API makes it possible to read the contents of a file, but I haven't yet found a way to modify or overwrite an existing file.

Upvotes: 0

Views: 2169

Answers (1)

Rob W
Rob W

Reputation: 348972

Prompt to open

To read a file, use the FileReader API (examples):

Prompt to save

To save the file, create an URL using URL.createObjectURL (the blob is constructed via the FileReader API, with type application/octet-stream), or using a data-URI (example).

Upvotes: 1

Related Questions