The this
pointer is different inside the callback function. So, you need to change it like this:
save : function(component) {
// ...
var fr = new FileReader();
var helper = this;
fr.onload = function() {
var fileContents = fr.result;
var base64Mark = 'base64,';
var dataStart = fileContents.indexOf(base64Mark) + base64Mark.length;
fileContents = fileContents.substring(dataStart);
alert("WORKING"); //check at this point- alert works
helper.upload(component, file, fileContents);
alert("DID IT WORK?"); // This alert not shown so upload call not working
};
fr.readAsDataURL(file); //fr.onload function triggered from here
},
upload: function(component, file, fileContents)
{ alert("Here"); //NEVER CALLED
}
See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/this