ByteArray of file being corrupted with javascript when I send to java

I want to get the bytes of a selected file in javascript and send it to java, however the way.

I tried this:

     // Evento de abertura do arquivo
    $scope.openFile = (evt) => {

         var f = document.getElementById('files').files[0],
         r = new FileReader();
     r.onloadend = function(e) {
         var myArrayJS = e.target.result;

         console.log(myArrayJS);

     };
     r.readAsDataURL(f);
  }

My java variable for file:

private byte[] bytesFile = new byte[1024 * 4];

But when I send a file java with ajax post request, when I try to save the file locally in java, the file gets broken. because it is corrupted? How do I send the correct form to java?