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

后端 未结 4 573
抹茶落季
抹茶落季 2021-01-11 11:59

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

4条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-01-11 12:18

    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

提交回复
热议问题