I used multer to download the image and save the path of the image to the database, and then how can I get the image from the client and show it on the screen?
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
Getting an image from the database using path images on the client side
Programing Coderfunda
November 10, 2023
No comments
Related Posts:
Pest Driven Laravel Course is now on LaracastsChristoph Rumpel's Pest Driven Laravel course is now live on Laracasts and available to subscribers immediately. Learn about resources that can help g… Read More
Entity Framework Core: A second operation started on this context before a previous operation completedI'm working on a ASP.Net Core 2.0 project using Entity Framework Core And in one of my list methods I'm getting this error: InvalidOperation… Read More
Call component method when service's signal updatesLet me preface this question with the fact that I started learning Angular about a month ago. Basically, I have a searchbar component and several di… Read More
originalError: ConnectionError: Login failed for user 'userName' when connecting Node.js to SQL ServerI am trying to connect Node.js to SQL Server for the first time. I would greatly appreciate some help. This function makes the connection: import co… Read More
How to "copy the Oracle JDBC driver into sonarqube_extensions/jdbc-driver/oracle"?I’m setting up Sonarqube according to Install the server and there I see a very strange instruction: a. Start the SonarQube container with the embedde… Read More
0 comments:
Post a Comment
Thanks