title: file upload not working in express js using ejs view engine
body: <p>I have tried to do file upload in express js project. used ejs as default view engine.</p>
  <p>file not uploaded to /uploads folder.</p>
  <p>here is my code below.</p>
  <p>in app.js file have imported required packages</p>
  <p>in routes/index.js route file created route</p>
  <pre><code>router.get('/index',indexController.index);
  router.post('/insertion',indexController.insertion);
  
  module.exports = router;
  </code></pre>
  <p>in controllers/indexController.js</p>
  <pre><code>const multer = require('multer');
  const path = require('path');
  
  const storage = multer.diskStorage({
      destination:function(req,file,cb)
      {
          cb(null,'./../uploads');
      },
  
      filename:function(req,file,cb)
      {
          callback(null,file.originalname);
      }
  });
  
  var upload = multer({storage:storage}).single('resume');
  
  exports.insertion = function(req,res)
  {
      var file = req.files.resume;
      upload(req,res,function(err){
          if(err)
          {
              console.log(err);
          }else{
              console.log('file uploaded successfully!');
          }
      });
  
      res.end();
  }
  </code></pre>
  <p>in views/registration.ejs file</p>
  <pre><code>&lt;form name=&quot;registration&quot; action=&quot;/insertion&quot; enctype=&quot;multipart/form-data&quot; method=&quot;POST&quot;&gt;
                                      &lt;div class=&quot;form-group&quot;&gt;
                                          &lt;label&gt;Name&lt;/label&gt;
                                          &lt;input type=&quot;text&quot; class=&quot;form-control&quot; name=&quot;name&quot;&gt;
                                      &lt;/div&gt;
                                      
                                      &lt;div class=&quot;form-group&quot;&gt;
                                          &lt;label&gt;Resume&lt;/label&gt;
                                          &lt;input type=&quot;file&quot; name=&quot;resume&quot; class=&quot;form-control&quot; &gt;
                                      &lt;/div&gt;
                                      &lt;div class=&quot;form-group&quot;&gt;
                                          &lt;input type=&quot;submit&quot; class=&quot;btn btn-primary&quot; name=&quot;submit&quot; value=&quot;Submit&quot;&gt;
                                      &lt;/div&gt;
                                  &lt;/form&gt;
  </code></pre>
  <p>file uploading not working .. i need to upload the file under uploads folder which is created in root directory</p>