import multer from 'multer';
const storageConfig = multer.diskStorage({
destination: (req, file, cb) => {
cb(null, './images')
},
filename: (req, file, cb) => {
cb(null, Date.now() + '-' + file.originalname)
}
})
const upload = multer({storage: storageConfig});
let path = '';
app.post('/upload',upload.single('image'), (req, res) => {
res.setHeader('Access-Control-Allow-Origin', '
http://localhost:3000');
/> if(req.file) {
console.log(req.file);
path = req.file.path;
res.send('hi')
return;
}
res.send('bye')
})
after I received the file path I saved it in the database, but I don’t know how to use it later to show this picture on the screen
0 comments:
Post a Comment
Thanks