How to read/write local files through a web page?

praneybehl picture praneybehl · Aug 19, 2012 · Viewed 29.6k times · Source

I am writing a html based app, and want to store and retrieve data from local file. This app will not be hosted on a web server.

Can anyone please help enlighten the topic on how can this be done?

Answer

Daniil Ryzhkov picture Daniil Ryzhkov · Aug 19, 2012

You should use FileSystem API of HTML5:

window.requestFileSystem(window.TEMPORARY, 5*1024*1024, function(){
    fs.root.getFile('test.dat', {}, function(fileEntry) {
        fileEntry.file(function(file) {
            // Here is our file object ... 
        });
    });
}, errorHandler);

Checkout FileSystem API for more reference

Visit The HTML5 Test to test browser support