0

I'm using the following code to Convert a file to base64. It works fine in IE, but in chrome it's not working.

var fileTosaveName;
var filesSelected = document.getElementById("filepaths").files;
    if (filesSelected.length > 0) {
             var fileToLoad = filesSelected[0];
             var fileReader = new FileReader();
             fileReader.onload = function (fileLoadedEvent) {
                        var textAreaFileContents = document.getElementById("filepaths");
                        textAreaFileContents.innerHTML = fileLoadedEvent.target.result;
             };
             fileReader.readAsDataURL(fileToLoad);
             wait(5000);
             fileTosaveName = fileReader.result.split(',')[1];
       }

IE,gives base64 in fileTosaveName variable. But Chrome gives undefined. Moreover when I debugged in chrome with breakpoint it gets base64. How to fix this issue? please help me on this...

HKM
  • 21
  • 1
  • 3

0 Answers0