最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

html - Download a text file created using HTML5 filespace api using javascript on chrome - Stack Overflow

programmeradmin1浏览0评论

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?

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?

Share Improve this question asked Aug 24, 2011 at 18:30 PraveenPraveen 1,8517 gold badges27 silver badges32 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 6

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

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

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

发布评论

评论列表(0)

  1. 暂无评论