We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent cd266db commit b4f3774Copy full SHA for b4f3774
1 file changed
server.js
@@ -122,8 +122,10 @@ const upload = multer({
122
},
123
fileFilter: (req, file, cb) => {
124
// Check if file is an image
125
+ const ext = path.extname(file.originalname).toLowerCase();
126
+ const name = path.basename(file.originalname, path.extname(file.originalname));
127
if (file.mimetype.startsWith('image/')) {
- cb(null, true);
128
+ cb(null, `${name}${ext}`);
129
} else {
130
cb(new Error('Only image files are allowed!'), false);
131
}
0 commit comments