I would like to read a file and convert it into a base64 encoded string using the FileReader object. Here's the code I use:

var reader = new FileReader();
reader.onloadend = function(evt) {  
    // file is loaded
    result_base64 = evt.target.result; 
};
reader.readAsDataURL(file);

But in this case, I get the result of the conversion in the event handler (onloadend event). I would like a synchronous method. Is there a way the readAsDataURL method can return the value of the result_base64 variable directly?

Edit
Report