dqu92800 2016-06-13 09:29
浏览 95
已采纳

通过使用Node作为json从MySQL获取blob图像并将其打印到PHP中

I'm trying to make a basic image like this :

<img src='myImage' />

It's easy yeah ? But my image is stored as a blob in my MySQL BDD.
Already easy yeah ? the answer is here.
->Nope because I'm getting my SQL lines by Node sending it to my PHP as a JSON file. So the PHP will receive an array (The image is an array with a lot of numbers and the PHP's function named "base64_encode" need a String as paramater, and not an Array). I have to convert this array to an image to print it. But i don't find how to.

Anybody know ?

Image to explain here.
var_dump($myImg) ->

array(25890) { [0]=> int(137) [1]=> int(80) [2]=> int(78) [3]=> int(71) [4]=> int(13) [5]=> int(10) [6]=> int(26) [7]=> int(10) [8]=> int(0) [9]=> int(0) [10]=> int(0) [11]=> int(13) [12]=> int(73) [13]=> int(72) [14]=> int(68) [15]=> int(82) [16]=> int(0) [17]=> ...
  • 写回答

1条回答 默认 最新

  • duanli0687 2016-06-13 09:59
    关注

    Your array contains every single char as separate element as int. You must iterate by this array and convert it into char by chr function and concatenate in one string:

    $string = '';
    foreach ($yourArray as $el) {
      $string .= chr($el);
    }
    

    And now you can do with $string whatever you want, eg convert it with base64_encode

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 求差集那个函数有问题,有无佬可以解决
  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥65 汇编语言除法溢出问题