I have a pretty simple function that is reading a file with HTML 5 FileReader:
var reader = new FileReader();
var currentFileType = file.type;
reader.onloadend = readCompleted;
reader.onerror = fail;
reader.readAsArrayBuffer(file);
and the readCompleted callback function looks like this:
function readCompleted(evt) {
if (evt.target.readyState != FileReader.DONE) {
return;
}
// The binary data is the result.
var requestData = evt.target.result;
// SOME MORE CODE HERE
}
Thing is that 'evt' parameter is passed by default. How can I pass one additional parameter to this callback function in order to have currentFileType variable available? I want this function signature to look like this: function readCompleted(evt, fileType) {//code here} and pass somehow currentFileType to it.