node.jsexpress-fileupload

Express fileupload mv() function override the existing file if the same name is given?


This is my code:

  if (req.files && req.files.logo) {
    const logo = req.files.logo
    logo.mv('./static/' + logo.name)
    fields['logo'] = logo.name
  }

so if the file with the same name is uploaded then does the above logo.mv function call will override the previously uploaded file?


Solution

  • Yes, you should change the name if you want to keep the file history.