title: from node.js server side: photo upload to facebook
body: <p>According to facebook documentation, <a href="http://developers.facebook.com/docs/reference/api/album/" rel="nofollow">http://developers.facebook.com/docs/reference/api/album/</a>, to upload a photo, source type should be <strong>"multipart/form-data"</strong></p>
  
  <p>Now I got the image file from client to server side in node.js using 'connect-form'. and I am using 'facebook-js' module to upload the photo to facebook as,</p>
  
  <pre><code>app.post('/', function(req, res, next){
  
    req.form.complete(function(err, fields, files){
      if (err) {
        next(err);
      } else {
        console.log('uploaded ', files.source.filename, 'to', files.source.path);
  
        fb.apiCall('POST', '/me/photos',
          {access_token: fields.access_token, 
               message: fields.message, 
               **source:files.source**},
          function (error, response, body) {
              if (error) {
                  console.log('Error in facebook Photo UPLOAD', error);
                  return;
              }
            res.redirect('back');
          }
        );
  </code></pre>
  
  <p>The above throws an error as files.source is not encoded as "multipart/form-data"..
  May I know what needs to be done here ? Do I have to put the file into memory and then use it in source ?</p>