In PHP, The hexadecimal image data is displayed on the html img Tag (implementation method ),

Source: Internet
Author: User

In PHP, The hexadecimal image data is displayed on the html img Tag (implementation method ),

A production database of SQLServer2008 of the customer company has been as large as 18 GB for more than a year. It turns out that images in the system are directly stored in the database as hexadecimal strings. I have to use PHP to display it on the html page, and it takes no time.

<? Php // read from the database: The hexadecimal string of the image $ icon_hex = '89504e470d0a1a0a0000000d494844520000001c0000001201030010972c92ca '. 'authorization '. 'authorization '. 'authorization'; $ imgdata = base64_encode (pack ('H * ', $ icon_hex); echo'  ';?>

Reference: Convert base64 to image

Note that:When the img label is displayed, you must add the file header Description: "data: image/png; base64,", which has taken me for a long time.

In the above PHP article, the hexadecimal image data is displayed on the img tag of html (implementation method), which is all the content shared by xiaobian. I hope to give you a reference, we also hope that you can support the customer's home.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.