title: If i am getting the doc file using javascript and sending it to external server it is showing weird text
body: <p>I am sending a file to an external server using ajax and api.I attached a file and then when i clicked on the upload button. It gets the content of the file and then send it to the external server using it's API. The request must be in json otherwise it rejects the data</p>
  
  <p>Below are my code</p>
  
  <pre><code>&lt;form enctype="multipart/form-data" id="form_submit_new_resume" method="POST" action="" onsubmit="return false;"&gt;
  &lt;input type="file" name="textfile" id="textfile"&gt;
  &lt;input type="button" onclick="submitform()"&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>Below is my javascript file</p>
  
  <pre><code>function submitform(){
  var filesSelected = document.getElementById("textfile").files;
  if (filesSelected.length &gt; 0)
      {   document.getElementById('loading').style.display="block";
          var fileToLoad = filesSelected[0];
  
          var fileReader = new FileReader();
  
          fileReader.onload = function(fileLoadedEvent) 
          {
              var textAreaFileContents = document.getElementById
              (
                  "textAreaFileContents"
              );
  
              var fileName = fileToLoad.name;
              var base64encode = fileLoadedEvent.target.result;
  
              jQuery.ajax(
  
  {
  
  url : "https://api.resumatorapi.com/v1/applicants",
  
  type: 'POST',
  
  dataType : "json",
   contentType : "application/json",
  
  data: '{"apikey":"apikey", "resumetext" : "'+base64encode+'"}',
  
  }
  
  )
  }
  </code></pre>
  
  <p>It successfully upload the file but when i see the file on server then it is showing invalid file.<a href="https://i.stack.imgur.com/bJPuv.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bJPuv.png" alt="enter image description here"></a></p>
  
  <p>If i use php's inbuilt function get_file_content then it is showing the correct text but i want to do it through ajax.Is there any other way to get the exact content of a doc file using jquery or javascript?</p>