Py学习  »  DATABASE

nodejs/express在html页面上将mysql blob显示为图像

goryef • 5 年前 • 642 次点击  

我试图将存储在mysql表中的blob显示为网页上的图像。 下面是用于从数据库中提取图像的查询:

  let imageQ = "select profile_image from ut_users where ut_id = '1234'";
  let profile_image= JSON.parse(JSON.stringify(result[0].profile_image));
  let bufferBase64 = new Buffer( profile_image, 
  'binary').toString('base64');


  res.render('dashboard', {profile_image: bufferBase64});

和HTML:

 <img src= "data:image/jpg;base64,<%= profile_image %>"
           style="max-width: 90%; padding-top: 5%; padding-left: 5%;">

不显示图像。 提前感谢您的指导。

Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/46338
 
642 次点击