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?
Web browsers (and JavaScript) can only access local files with user permission. To standardize the file access from the browser, the W3C published the HTML5 File API in 2014. It defines how to access and upload local files with file objects in web applications.
Using Google Chrome to access local files is as easy as pressing Ctrl + O at the same time. This interface will open, allowing you to navigate to whichever file or folder is needed. There are several types of files which can be opened using Chrome. These include pdf, mp3 files, some video files and most document files.
Click File > Save As and choose the location where you want to save your document. Name your file. In the Save as type list, choose Web Page, Filtered.
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
Try HTML 5 FileSystem API
Below links has details
http://dev.w3.org/2009/dap/file-system/pub/FileSystem/
http://www.html5rocks.com/en/tutorials/file/filesystem/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With