title: Nodejs POST request multipart/form-data
body: <p>I am trying to upload a photo via a POST request with the <a href="https://github.com/mikeal/request"><code>request module</code></a></p>
  
  <p>According to the readme I should just be able to do this</p>
  
  <pre><code>var r = request.post("http://posttestserver.com/post.php", requestCallback)
  var form = r.form()
  form.append("folder_id", "0");
  form.append("filename", fs.createReadStream(path.join(__dirname, "image.png")));
  
  function requestCallback(err, res, body) {
      console.log(body);
  }
  </code></pre>
  
  <p>The problem is, this doesn't work. I get a reply from the test server saying it dumped 0 post variables.</p>
  
  <p>I have confirmed that the server is in working condition with this little html page</p>
  
  <pre><code>&lt;html&gt;
      &lt;body&gt;
          &lt;form action="http://posttestserver.com/post.php?dir=example" method="post" enctype="multipart/form-data"&gt;
              File: &lt;input type="file" name="submitted"&gt;
              &lt;input type="hidden" name="someParam" value="someValue"/&gt;
              &lt;input type="submit" value="send"&gt;
          &lt;/form&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>So the question is, what am I doing wrong with the request module? Is there a better way to send <code>multipart/form-data</code> with node?</p>