admin管理员组

文章数量:1405621

I am aware that the HTML5 Filesystem API gives you access to a sandboxed file system. Let's say I write a file to the filesystem. Is it possible to let the user save that file to their actual file system? I would like to be able to tell the user where the file is written so that they may access it but that does not seem to be possible.

My only idea is to read the file as a data url and make a hyperlink that the user can save, but that has scalability issues in terms of file size.

I am aware that the HTML5 Filesystem API gives you access to a sandboxed file system. Let's say I write a file to the filesystem. Is it possible to let the user save that file to their actual file system? I would like to be able to tell the user where the file is written so that they may access it but that does not seem to be possible.

My only idea is to read the file as a data url and make a hyperlink that the user can save, but that has scalability issues in terms of file size.

Share Improve this question asked Oct 29, 2012 at 21:39 knpwrsknpwrs 16.6k12 gold badges66 silver badges104 bronze badges 1
  • Note really. You can create a local filesystem path based on browser though (possibly) that they could go to. – Linuxios Commented Oct 29, 2012 at 21:48
Add a ment  | 

2 Answers 2

Reset to default 4

You can use the URL obtained from the toURL method as the value for a link's href attribute, which link in addition has a download attribute. Clicking on the link will then prompt the user to save the contents on her filesystem.

Quoting MDN - Basic Concepts About the Filesystem API:

You can, however, export a file from a web app to a desktop app. For example, you can use the File API, create a blob, redirect an iframe to the blob, and invoke the download manager.

Also, the very page I linked to before discusses FileEntry's toURL() method which returns a url in the form of filesystem:.

Here is another article on how to make the browser download a file from a url.

本文标签: javascriptHTML5 Filesystems APILetting Users Save Files to Their Actual FilesystemStack Overflow