'multer node js upload image
when i send a new image the link apper like this: uploads\854645135.jpg i want to change this antislash"" to slash"/" cause i can't find this data in frontend
const uploadRouter = express.Router();
const storage = multer.diskStorage({
destination(req, file, cb) {
cb(null, 'uploads/');
},
filename(req, file, cb) {
cb(null, `${Date.now()}.jpg`);
},
});
const upload = multer({ storage });
uploadRouter.post('/',isAuth, upload.single('image'), (req, res) => {
res.send(`/${req.file.path}`);
});
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|