title: Getting null when I send file reactjs to express server
body: <p>I am trying to send files using react js to express the server. but when I send a file from the frontend I got a null value into the server.</p>
  <p>Frontend: I have consol log into the frontend everything is ok into the frontend.</p>
  <pre><code>const ProductImport = function () {
      const [file, setFile] = useState&lt;any&gt;();
      const [isLoading, setIsLoading] = useState&lt;boolean&gt;(false);
      const [fileName, setFileName] = useState(&quot;&quot;);
  
      const saveFile = (e) =&gt; {
          setFile(e.target.files[0]);
          setFileName(e.target.files[0].name);
      };
      const uploadFile = async (e: any) =&gt; {
          e.preventDefault()
          const formData = new FormData();
          formData.append(&quot;file&quot;, file);
          formData.append(&quot;fileName&quot;, fileName);
  
          console.log(file);
          console.log(fileName);
  
          fetch('http://localhost:5000/upload-excel', {
              method: 'POST',
              body: formData
          })
              .then(response =&gt; response.json())
              .then(data =&gt; {
                  if (data.insertedId) {
                      alert('excel Added')
                  }
              })
              .catch(error =&gt; {
                  console.error('Error:', error);
              });
  
      };
      return (
          &lt;form onSubmit={uploadFile}&gt;
              &lt;label htmlFor=&quot;formGroupExampleInput&quot; className=&quot;form-label&quot;&gt;Example label&lt;/label&gt;
              &lt;input type=&quot;file&quot; onChange={saveFile} /&gt;
              &lt;button type=&quot;submit&quot;&gt;Upload&lt;/button&gt;
          &lt;/form&gt;
      )
  }
  </code></pre>
  <p>Backend: The problem is with the backend, I got null</p>
  <pre><code>//MIddleware
  app.use(cors())
  app.use(express.json())
  app.use(cors());
  app.use(fileupload());
  app.use(express.static(&quot;files&quot;));
  app.use(bodyParser.json({ limit: &quot;50mb&quot; }));
  app.use(bodyParser.urlencoded({ limit: &quot;50mb&quot;, extended: true, parameterLimit: 50000 }));
  
       app.post(&quot;/upload-excel&quot;, async (req, res) =&gt; {
              const file = req.files;
              console.log(file);
          });
  </code></pre>
  <p>Frontend console:</p>
  <p><a href="https://i.stack.imgur.com/9NlKE.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9NlKE.png" alt="enter image description here" /></a></p>
  <p>Backend console:</p>
  <p><a href="https://i.stack.imgur.com/vgGJA.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/vgGJA.png" alt="enter image description here" /></a></p>