title: Node.js + Express: Upload a file without reloading page
body: <p>I am creating a chat application using Node.js, and would like to have a file upload feature. While I can get the file uploaded, the browser would always be redirected to another link or page refreshed, and this of course disrupts the chat.</p>
  
  <p><strong>First</strong> I tried using Express to do it:</p>
  
  <p>index.html:</p>
  
  <pre><code>&lt;form id="fileSendButton" action="/" method="post" enctype="multipart/form-data"&gt;
      &lt;input type="text" name="title"&gt;&lt;br&gt;
      &lt;input type="file" name="upload" multiple="multiple"&gt;&lt;br&gt;
      &lt;input type="submit" value="Upload"&gt;
  &lt;/form&gt; 
  </code></pre>
  
  <p>app.js:</p>
  
  <pre><code>app.post('/', function(req, res){
      //some validation and rename file
      res.send();
      return false;
  });
  </code></pre>
  
  <p><strong>Next</strong> I tried using AJAX, but still couldnt do it, whenever the AJAX POST to the Node.js server, it would reload the page. My AJAX code anyway:</p>
  
  <p>index.html:</p>
  
  <pre><code>$.ajax({  
      type: "POST",  
      url: "/",  
      data: formdata,  
      processData: false,
      contentType: false,
      success: function (res) {
          document.getElementById("chatText").innerHTML = res; 
      } 
  });  
  return false;
  </code></pre>
  
  <p><strong>Third</strong> I went to look at Uploadify, but didnt want to add Flash dependancy to my site, so I didnt implement it.</p>
  
  <p>Anyone can help me please? I dont want a page reload when a file is uploaded.</p>