title: Sails Js POST request
body: <p>I have a html form that makes a POST request to <code>/upload/upld</code> in my sails app. My aim is to have two parameters: a photo to be uploaded and the location where the photo was taken. My upload controller is supposed to upload the file to a directory with the value of the location parameter.</p>
  
  <pre><code>      &lt;form method="post" action="/upload/upld" enctype="multipart/form-data"&gt;
          &lt;span class="btn btn-default btn-file wow bounceIn top-buffer"&gt;
            Browse &lt;input type="file" name="photo"&gt;
            &lt;input type="hidden" name="location" value="istana" /&gt;
          &lt;/span&gt;
            &lt;input type="submit" class="btn btn-primary wow bounceIn top-buffer"&gt;
        &lt;/form&gt;
  </code></pre>
  
  <p>Unfortunately this code does not seem to be working. The output on console shows the following whenever I upload just a single file. I'm not sure why the upld method seems to run twice on a single upload.</p>
  
  <pre><code>{ location: 'istana', id: undefined }
  istana
  { id: undefined }
  undefined
  </code></pre>
  
  <p>My upload controller looks like this:</p>
  
  <pre><code>    upld: function (req, res) {
              var params = req.params.all();
              console.log(params);
              var this_location = params.location;
              console.log(this_location);
              req.file('photo').upload({ dirname:require('path').join('./',this_location)},function (err, files) {
                      if (err){
                              return res.serverError(err);
                      }
                      return res.view('homepage',{
  
                                      message: files.length + ' file(s) uploaded successfully!',
                                      files: files
                              }
                      );
              });
      }
  </code></pre>