Upload file using multer after specific database operation in node js
问题 I am using multer to upload files via express . Is there a way to perform a database operation before uploading the file? I need to perform a conditional check whether the user insertion in the database was successful or not depending on that, the file upload should be performed. 回答1: To use multer as per required you can use the following code: var path = require('path'); var multer = require('multer'); var storage = multer.diskStorage({ destination: function(req, file, callback) { callback