I am trying to download a text file that i created using the file space api on chrome. I am unable to download it. I can only view it on the chrome browser itself.
location.href = fileEntry.toURL();
That is the line of code i currently use to download it.
Could i use content-disposition to force download a .txt file? if so, how?
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With