Error loading file with File Editor

1

I'm trying to make a html editor, but I can not read the file in the editor using JavaScript .

 var loadFile = function(name) {
        fileSystem.root.getFile(name, {}, function(fileEntry) {
          currentFile = fileEntry;
          fileEntry.file(function(file) {
            var reader = new FileReader();
            reader.onloadend = function(e) {
              updateVisualEditor(this.result);
            }
          }, fsError);
        }, fsError);
      };

    
asked by anonymous 31.03.2016 / 13:45

1 answer

1

I think what's missing is you read the file.

Enter the following line in your code and take the test.

  

reader.readAsText (file);

 var loadFile = function(name) {
        fileSystem.root.getFile(name, {}, function(fileEntry) {
          currentFile = fileEntry;
          fileEntry.file(function(file) {
            var reader = new FileReader();
            reader.onloadend = function(e) {
              updateVisualEditor(this.result);
            }
            reader.readAsText(file);
          }, fsError);
        }, fsError);
      };
    
31.03.2016 / 13:47