Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML 5 File API

Tags:

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.

like image 239
AJ. Avatar asked Jan 22 '10 14:01

AJ.


People also ask

How to access a file using HTML5 File API?

Before the HTML5 file API can access a file from the local file system, the user has to select the file to give access to. For security reasons selecting files is done via the <input type="file"> HTML element. Here is an input element example: By itself the input element is not enough. You need an onchange listener too. Here is how that looks:

What is FileSystem API in HTML5?

HTML5: FileSystem API – Create Files and Store Them Locally Using JavaScript and Webkit. The FileSystem-API allows the creation of files and folders as well as their local storage using JavaScript.

What is the HTML5 File API and is it safe?

The HTML5 file API enables JavaScript inside HTML5 pages to load and process files from the local file system. Via the HTML5 file API it is possible for JavaScript to process a file locally, e.g. compress, encode or encrypt it, or upload the file in smaller chunks. Of course the HTML5 file API raises some security concerns.

What is HTML5 and how does it work?

HTML5 saw the introduction of a number of new APIs that can be used to handle files in the browser. These APIs make it much easier to accomplish tasks like reading and writing files or uploading a file created using JavaScript.


1 Answers

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/

like image 163
Paul Rouget Avatar answered Sep 23 '22 02:09

Paul Rouget