Reputation: 667
When I use this module app.use(express.bodyParser({ keepExtensions: true, uploadDir: __dirname + "/public/adminupload" }));
.My files are uploaded to __dirname + "/public/adminupload"
directory but the file name is change randomly, new name is differently with req.files.file.name
. So how can I get the new name?
Upvotes: 1
Views: 2798
Reputation: 48003
You can get entire path from req.files.file.path
. You can extract the filename like this:
path = require('path')
console.log(path.basename(req.files.file.path));
Upvotes: 1