PHP HTML image output

后端 未结 4 1225
终归单人心
终归单人心 2021-02-08 08:02

In the PHP manual for base64_encode() I saw the following script for outputting an image.



        
4条回答
  •  悲&欢浪女
    2021-02-08 08:48

    You have to save your image as a PNG first, and then read from it to get its contents as a value.

    http://www.php.net/manual/en/function.imagepng.php

    imagepng() does not return the PNG file. It outputs it directly to the browser and then returns a boolean meaning success or failure.

    (from php.net:) PHP internally works with a temporary file when sending the image to the browser, so you'll gain nothing by calling imagepng() twice.

提交回复
热议问题