title: how to upload a file in nodejs
body: <p>HTML code:-</p>
  
  <pre><code>&lt;html&gt;
  &lt;body&gt;
  &lt;form action="http://localhost:3000/api" method="post" enctype="multipart/form-data"&gt;
      &lt;input type="file" name="file"&gt;
      &lt;input type="submit"&gt;
  &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>The code in nodeJS is</p>
  
  <pre><code>app.post('/api',function (req, res) {
      //JSON.stringify(req.files);
      console.log(JSON.stringify(req.files));
      var file = req.files.file;
      var stream = fs.createReadStream(file.path);
  });
  </code></pre>
  
  <p>I want to print the details of the-files.</p>
  
  <p>I am getting error</p>
  
  <blockquote>
    <p>TypeError: Cannot read property 'file' of undefined
       at /Users/mAddy/Desktop/check1/server.js:27:25</p>
  </blockquote>