Error loading file with File Editor

Asked

Viewed 30 times

1

I’m trying to make a publisher of html, but I’m not able to 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);
      };

inserir a descrição da imagem aqui

  • It would be interesting to add error details.

  • No error appears, just not the new tab opens blank

1 answer

1


I believe what’s left is for you to read the file.

Insert the following line into your code and 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);
      };

Browser other questions tagged

You are not signed in. Login or sign up in order to post.