Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Errors with File plugin on PhoneGap application

I'm trying to save user information in a phonegap application but upon trying

window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function (fs) {

console.log('file system open: ' + fs.name);
fs.root.getFile("newPersistentFile.txt", { create: true, exclusive: false }, function (fileEntry) {

    console.log("fileEntry is file?" + fileEntry.isFile.toString());
    // fileEntry.name == 'someFile.txt'
    // fileEntry.fullPath == '/someFile.txt'
    writeFile(fileEntry, null);

}, onErrorCreateFile);

}, onErrorLoadFs);

I get the error

Uncaught ReferenceError: onErrorLoadFs is not defined

and on commenting it out I get

Uncaught ReferenceError: onErrorCreateFile is not defined

and finally on commenting that out I get

Uncaught ReferenceError: writeFile is not defined

I am also running

window.addEventListener('filePluginIsReady', function(){ 

                        console.log('File plugin is ready');

                    requestFileSystem(LocalFileSystem.TEMPORARY, 5 * 1024 * 1024, function (fs) {

                        console.log('file system open: ' + fs.name);
                        createFile(fs.root, "newTempFile.txt", false);

                }, onErrorCreateFile);

Incase the error was stemming from the file plugin not being ready but again I'm met with the error

Uncaught ReferenceError: createFile is not defined

Any suggestions or help would be greatly appreciated! Thanks for your time!

like image 599
Christopher Coyle Avatar asked Aug 01 '26 02:08

Christopher Coyle


1 Answers

onErrorCreateFile and onErrorLoadFs are functions that you need to define, e.g.:

function onErrorCreateFile() {
    console.log("Create file fail...");}

function onErrorLoadFs() {
    console.log("File system fail...");
}
like image 113
darwin Avatar answered Aug 03 '26 17:08

darwin