Click here to Skip to main content
15,891,864 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to upload an image to the blob field in mysql using nodejs and use angular to display that blob as an image any ideas how to do it?

What I have tried:

Nodejs:-
const image = fs.readFileSync(file.path);
let base64data = image.toString('base64');
db.query(qr, (err, result) => {
if(err){
res.send({
err
})
}else{
res.send({
message: "data sent successfully"
})
}
})
Angular:-
ts file: -
 display(){
    const reader = new FileReader();
    this.http.get('http://localhost:5000/image').subscribe((res:any)=>{
      console.log(res);
      this.readData = res.response[0];
  })
 
.html file:-
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900