title: Uploading recorded audio to the node js server using Multer
body: <p>I want to upload the recorded audio file to the Node js server using multer But I am not getting the file on the server. Here is my code .What should I do ?</p>
  
  <p>JS CLIENT SIDE CODE :</p>
  
  <pre><code>mediaRecorder.onstop=(e)=&gt;{
            let blob=new Blob(chunks,{'type':'audio/mp3;'});
            chunks=[];
            let audioURL=window.URL.createObjectURL(blob);
            audio.src=audioURL;
            var data = new FormData();
            var request = new XMLHttpRequest();
            data.append('file',blob,'audio.mp3');
            request.open('post','/upload'); 
            request.send(data);
            console.log('File sent');
          }
  </code></pre>
  
  <p>SERVER SIDE CODE :</p>
  
  <pre><code>app.post('/upload', upload.single('file'), function (req, res, next) {
  
            console.log(req.file); 
            var oldpath = req.file;
            var newpath = __dirname;
            fs.readFile(oldpath, function (err, data) {
            fs.writeFile(newpath, data, function (err) {
                  if (err) throw err;
                  res.end();
              });
  
    })
  })
  </code></pre>
  
  <p>And I am getting this error now :
  <a href="https://i.stack.imgur.com/v0vg6.png" rel="nofollow noreferrer">See the output Here and Error</a></p>