Coverting Hex to Image in PHP?

前端 未结 2 970
别那么骄傲
别那么骄傲 2020-12-02 02:13

I am developing mobile app which talks with server via PHP Webservice. This is my first time using PHP. I managed to upload data in to database. Now i need to s

2条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-02 02:42

    Convert the HEX string to binary:

    $binary = pack("H*", $hex);
    

    pack("H*", ...) is equivalent to hex2bin, which is available since PHP 5.4.

    Write it to disk:

    file_put_contents("file.png", $binary);
    

提交回复
热议问题