title: Node.js multer unable to store files and string data
body: <p>I am using Node.js and multer to store files but am unable to save them.</p>
  <p>From the React side, I send data in formdata using post request, browser is showing files and data, node receives the request and in the req.files I get the file as well.</p>
  <p>I tried upload.any(), upload.array(), but nothing shows the file in req.file or req.files. When I try upload.single(&quot;filename&quot;), console shows the data.</p>
  <p>I have checked the req.files – it shows:</p>
  <pre><code>  name: '783px-Test-Logo.svg.png',
    data: &lt;Buffer 89 50 4e 47 0d 0a 1a 0a 00 00 00 0d 49 48 44 52 00 00 03 0f 00 00 01 67 08 06 00 00 00 e0 e4 75 c8 00 00 11 22 33 41 4d 41 00 00 b1 8f 0b fc 61 05 00 ... 18403 more bytes&gt;,
    size: 18453,
    encoding: '7bit',
    tempFilePath: '',
    truncated: false,
    mimetype: 'image/png',
    md5: '6a78913c131cfcd539813bd4b7c42459',
    mv: [Function: mv]
  }
  </code></pre>
  <p>So I am getting files here from the browser, but the problem is that it is creating an empty storage folder.</p>
  <p>These are my multer configurations:</p>
  <pre><code>const userTypes = require(&quot;../internal/users/consts/userTypes&quot;);
  const middlewares = require(&quot;../api/middlewares&quot;);
  const AssignmentsApi = require(&quot;../api/assignment&quot;);
  const multer = require('multer');
  
  
  let storage = multer.diskStorage({
      destination: function (req, file, cb) {
          cb(null, './storage')
      },
      filename: function (req, file, cb) {
          cb(null, file.originalname + '-' + Date.now())
      }
  });
  
  const upload = multer({ storage });
  
  module.exports = app =&gt; {
      const assignmentRouter = express.Router();
      assignmentRouter.use(middlewares.AuthMiddleware);
      assignmentRouter
          .route(&quot;/uploadnew&quot;)
          .post(middlewares.UserRolesMiddleware(userTypes.teacher),  upload.any(), function(req, res, next) {
              if (req.file) {
                  console.dir(&quot;req.file&quot;, req.file);
                  console.log(&quot;uploadnew files&quot;, req.file.assignmentFile);
                  return res.end(&quot;Thank you for the file&quot;);
              } else if (req.files) {
                  console.dir(&quot;req.files&quot;, req.files);
                  console.log(&quot;uploadnew files&quot;, req.files.assignmentFile);
                  return res.end(&quot;Thank you for the files&quot;);
              }
              res.end(&quot;Missing file&quot;);
          }); 
  }```
  </code></pre>