weixin_33722405 2019-07-20 12:26 采纳率: 0%
浏览 51

无法加载图像nodejs mysql

I insert image to the product but i can't display it in ejs..each product has 2 images..the productImageName should by the image and it's blob type in DB

app.get('/product', getProductPage);

getProductPage: (req,res) => {
    let query = "SELECT p.*,i.* FROM `product` AS p INNER JOIN `productimage` AS i ON p.productId = i.productId ";
    getConnection().query(query , (err, result) => {
      if (err) {
        return res.status(500).send(err);
      }else {
        console.log(result);
        res.render('product.ejs',{
          product:result
        });
      }
    })

my ejs :

<% product.forEach((product) =>{ %>
            <tr>
                  <td> <img id="productImage" src="data:image/png;base64,.base64_encode(<%= product.productImageNAme %>)"></td>
                  <td ><%= product.productName %></td>
                  <td><%= product.price %></td>
                <td><a href="/editProduct/<%= product.productId %>" id="edit" id="edit"> Edit</a></td>
              </tr>
              <% }) %>

I got this in console:

> RowDataPacket {
>     productId: 29,
>     productName: 'er',
>     price: '3',
>     productImageId: 8,
>     productImageName:
>      <Buffer 75 6e 64 65 66 69 6e 65 64 2d 31 35 36 33 36 32 30 30 34 35 38 35 36> } ]
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥20 有关区间dp的问题求解
    • ¥15 多电路系统共用电源的串扰问题
    • ¥15 slam rangenet++配置
    • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
    • ¥15 对于相关问题的求解与代码
    • ¥15 ubuntu子系统密码忘记
    • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
    • ¥15 保护模式-系统加载-段寄存器
    • ¥15 电脑桌面设定一个区域禁止鼠标操作
    • ¥15 求NPF226060磁芯的详细资料