With multer, you can't really control upload dynamically. However, what you can do is upload it in a temp folder, and then check if the id exists. If it exists in your database, you can move the file into another folder, otherwise, delete that file