Download a text file created using HTML5 api file space using javascript on chrome

I am trying to upload a text file that I created using api file space on chrome. I can not download it. I can only view it in the Chrome browser.

location.href = fileEntry.toURL(); 

This is the line of code that I am currently using to download it.

Can I use the content location to upload a .txt file? if so, how?

+6
source share
1 answer

Check out the FileSaver interface: http://www.w3.org/TR/file-writer-api/#the-filesaver-interface .

Here's a sample that does what you want: http://oftn.org/projects/FileSaver.js/demo/

Here's an HTML5Rocks post that describes usage in more detail: http://updates.html5rocks.com/2011/08/Saving-generated-files-on-the-client-side

+6
source

Source: https://habr.com/ru/post/895787/


All Articles