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 fluent的在模拟压强时使用希望得到一些建议
  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services
  • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏
  • ¥15 模糊pid与pid仿真结果几乎一样
  • ¥15 java的GUI的运用
  • ¥15 Web.config连不上数据库
  • ¥15 我想付费需要AKM公司DSP开发资料及相关开发。
  • ¥15 怎么配置广告联盟瀑布流
  • ¥15 Rstudio 保存代码闪退