// Save a file in the FileSystem.
function saveFile(filename, content) {
filesystem.root.getFile(filename, {create: true}, function(fileEntry) {
fileEntry.createWriter(function(fileWriter) {
fileWriter.onwriteend = function(e) {
// Update the file browser.
listFiles();
// Clean out the form field.
filenameInput.value = '';
contentTextArea.value = '';
// Show a saved message.
messageBox.innerHTML = 'File saved!';
};
fileWriter.onerror = function(e) {
console.log('Write error: ' + e.toString());
alert('An error occurred and your file could not be saved!');
};
var contentBlob = new Blob([content], {type: 'text/plain'});
fileWriter.write(contentBlob);
}, errorHandler);
}, errorHandler);
}
Great writeup on how to use Javascript’s Filesystem API