title: Express & NodeJS : Accessing response parameters from Multipart form POST
body: <p>I have a simple form that allows the user to upload a file type image, and append the "category" type of the file to the response body, via a radio input selection.</p>
  
  <p>The file processing itself is handled as expected on the backend - however, when it comes to accessing parameters in the response body, I am receiving UNDEFINED as the parameter value. Can anyone lend some pointers on what I may have overlooked ?</p>
  
  <p>here is a sample of the mark-up and back end script:</p>
  
  <pre><code>    &lt;!DOCTYPE html&gt;
  &lt;html&gt;
  
      &lt;head&gt;
          &lt;script src="js/blueimp-gallery.min.js" async&gt;&lt;/script&gt;
          &lt;script src="js/bootstrap.min.js" async&gt;&lt;/script&gt;
          &lt;script src="https://code.jquery.com/jquery-3.1.1.min.js" async&gt;&lt;/script&gt;
          &lt;script src="js/script.js" async&gt;&lt;/script&gt;
          &lt;link rel="stylesheet" href="css/blueimp-gallery.min.css"&gt;
          &lt;link rel="stylesheet" type="text/css" href="css/style.css" /&gt;
      &lt;/head&gt;
  
      &lt;body&gt;
  
  
          &lt;div id="main"&gt;
              &lt;div class="navbar-wrapper" style="border: 12px solid black;"&gt;
                  &lt;ul&gt;
                      &lt;li&gt;&lt;a href="#"&gt;Login&lt;/a&gt;&lt;/li&gt;
                      &lt;li&gt;&lt;a href="#"&gt;Sign up&lt;/a&gt;&lt;/li&gt;
                  &lt;/ul&gt;
              &lt;/div&gt;
  
              &lt;div&gt;
                  &lt;form 
                          id              =  "uploadForm"
                          enctype         =  "multipart/form-data"
                          action          =  "/api/photo"
                          method          =  "post"&gt;
  
                      &lt;input type="file" name="userPhoto" /&gt;
                      &lt;input type="submit" value="Upload Image" name="submit"&gt;
  
                      &lt;label&gt;travel&lt;/label&gt;
                      &lt;input type="radio" value="travel"      name="cat"&gt;
                      &lt;label&gt;food&lt;/label&gt;
                      &lt;input type="radio" value="food"        name="cat"&gt;
                      &lt;label&gt;community&lt;/label&gt;
                      &lt;input type="radio" value="community"   name="cat"&gt;
                  &lt;/form&gt;
              &lt;/div&gt;
  
      &lt;/body&gt;
  &lt;/html&gt;
  
  
  
  
  
  
  
  app.post('/api/photo', function(req,res){
  
      console.log("request to upload image recvied.. upload in progress.");
      //console.log("res.catype() = TODO " + req.get("cat"));
  
  
      // Returning undefined*
      console.log("res.catype() = " + res.cat);
  
      // handle file persistence to disk.
      upload(req,res,function(err) {
          if(err) {
              return res.end("Error uploading file.");
          }
          res.end("File is uploaded");
      });
  });
  </code></pre>