0

I'm developing a web app that needs some sort of filesystem access. Ideally I'd want to be able to "Open..." a file into the app and then "Save" the file back to local filesystem at the location that the user opened it from.

Currently, we use a java applet to achieve this functionality, but since java is going out of style, we're needing to do this with javascript and html5.

Obviously, this can't be done because of security reasons built into browsers, so I'm trying to somewhat emulate it.

I'm using the html5 file api to successfully import/open the files, so that's half the battle. The hard part is getting the saving feature. I'm getting close using an iframe and content-disposition, but problems arise when browsers are set to automatically download the files to a downloads folder... users may get confused and be unable to locate the file they just downloaded.

So, my question is this: is there some sort of onSave event or some kind of way for the browser's "Save As..." window to return at least the filename that the user saved the file under?

Also, I've looked into the filesystem/fileWriter html5 apis, but from my understanding they're limited to only a sandboxed area of the local filesystem and only available in chrome dev releases.

Any help would be appreciated!

user1052474
  • 73
  • 1
  • 5
  • The short answer is [No](http://stackoverflow.com/questions/4309958/can-i-write-files-with-html5-js). – puk Nov 17 '11 at 19:09

1 Answers1

1

No, there is no way to do that with pure JavaScript. You can manage to trigger a download with data URIs or an iframe with some headers but you can't circumvent the browsers' download managers.

You can either use a Flash or Java applet to handle the saving for you, or ask the user to right click on the link and do save as, then he might be able to choose the destination.

One popular option using Flash is Downloadify.

Alex Turpin
  • 46,743
  • 23
  • 113
  • 145