title: Uploading file on change of file input
body: <p>I am trying to upload a file on change of file input but I can't get it to work because I am not so good with javascript. </p>
  
  <p>I did search on google and found this: <a href="https://stackoverflow.com/questions/166221/how-can-i-upload-files-asynchronously-with-jquery">How can I upload files asynchronously?</a></p>
  
  <p>I used it and tried to change it to how I want to use it. But I am getting the error </p>
  
  <pre><code>`Uncaught TypeError: Illegal invocation`
  </code></pre>
  
  <p>This is my function:</p>
  
  <pre><code>function uploadFile(formData){
      $.ajax({
          url: 'inc/ajax/uploadFile.php',  //Server script to process data
          type: 'POST',
          data: {'formData':formData},
          //Ajax events
          success: function(html){
              alert(html);
          }
      });
  }
  </code></pre>
  
  <p>I call the function like this:</p>
  
  <pre><code>$("input:file").change(function(){
      var file = this.files[0];
      uploadFile(file);
  })
  </code></pre>
  
  <p>And uploadFile.php</p>
  
  <pre><code>&lt;?php
   $formData = $_GET['formData'];
   echo $formData;
  ?&gt;
  </code></pre>
  
  <p>I am just testing and trying to return the file in php to see if I can get it to work. But I have no idea on how I have to call it in PHP or send it with AJAX. I know how to upload it with PHP once I can retrieve the $_FILES in PHP.</p>