title: How to upload files using nodejs and HAPI?
body: <p>Can anyone tell me How to upload files Using nodejs and HAPI?</p>
  
  <p>I am getting binary data inside the handler.</p>
  
  <p>Here is my html code:</p>
  
  <pre><code>function sendFormFromHTML(form) {
          //form = $(".uploadForm").form;
          var formData = new FormData(form);
          formData.append('id', '123456'); // alternative to hidden fields
          var xhr = new XMLHttpRequest();
          xhr.open('POST', form.action, true);
          xhr.onload = function(e) { alert(this.responseText) };
          xhr.send(formData);
          return false;
      } 
  
  
  
  &lt;form method="post" id="uploadForm" action="http://localhost:3000/api/uploadfiles" enctype="multipart/form-data"&gt;
      &lt;label for="upload"&gt;File (Binary):&lt;/label&gt;
      &lt;input type="file" name="upload" class="fileupload" /&gt;&lt;br/&gt;
  
      &lt;input type="button" class="submit" value="Submit" onclick="sendFormFromHTML(this.form);"/&gt;
    &lt;/form&gt;
  </code></pre>
  
  <p>Here is My Nodejs code:</p>
  
  <pre><code>server.route({
      method: 'POST',
      path: '/api/uploadfiles',
      config: {        
          handler: currentposition.uploadFiles,
      }
  });
  
  uploadFiles:function(req,reply){
      console.log(req.payload);
  }
  </code></pre>