6

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?

1 Answer 1

6

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

Sign up to request clarification or add additional context in comments.

1 Comment

You nee dot inluce this js file in your html github.com/eligrey/FileSaver.js then saveAs would work

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.