20

I hear that Firefox 3.6 adds support for the HTML local file API (Announcement here).

Does this mean that I can access local files from javascript?

Can anyone point me to examples for reading / writing local files?

I would love to be able to read / write simple text files.

Mohammed H
  • 6,326
  • 12
  • 72
  • 119
AJ.
  • 12,633
  • 18
  • 47
  • 62
  • That's a mistake in the announcement, though. The File API has very little to do with HTML5. – Ms2ger Jan 22 '10 at 18:40

5 Answers5

17

The only files you can access are files dropped from the desktop or files that has been selected from an <input/> tag. See the demo I've written here: http://hacks.mozilla.org/2009/12/uploading-files-with-xmlhttprequest/

rahul
  • 174,563
  • 47
  • 223
  • 254
Paul Rouget
  • 10,665
  • 2
  • 12
  • 10
3

It doesn't allow accessing arbitrary local files. It's more of a file upload improvement. For instance, you can have some Javascript accept a drag-and-drop file initiated by the user of the browser.

You can find the W3C spec on it here.

2

Take a look at the demo at hacks.mozilla.org.

Ruben
  • 136
  • 5
1

You can find a (mozilla-specific explanation of the API on the Mozilla Development Center.

David Schmitt
  • 54,766
  • 26
  • 117
  • 159
1

It's possible to write to local file system, but the user must complete a 'save as...' action. For now, no direct access to client file system. Take a look here

Dario Barilà
  • 505
  • 6
  • 5