PHP: Show JPG from Binary

后端 未结 2 1257
闹比i
闹比i 2021-01-16 03:22

I have a jpg blob thats been stored in an external DB and I\'m looking to display that as an image via php. The issue is whenever I set the Content-Type to

相关标签:
2条回答
  • 2021-01-16 03:51

    After continuing research I found this post PHP: create file from an HEX string

    With the following code I fixed the issue.

    <?php
    header('Content-Type: image/jpeg;');
    
    $data = 'The hex data';
    
    $data = pack('H*',$data);
    
    $im = imagecreatefromstring($data);
    
    imagejpeg($im);
    
    ?>
    
    0 讨论(0)
  • 2021-01-16 03:54

    Try $im = imagecreatefromstring($data); The output it by imagejpeg($im);

    0 讨论(0)
提交回复
热议问题