Displaying a Base64 images from a database via PHP

后端 未结 6 2196
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-05 18:21

I have this database that contains images as strings. Those strings look something like this:

data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEAYABgAAD...
         


        
6条回答
  •  天涯浪人
    2020-12-05 18:52

    If you are dealing with data stored in a PostgreSQL database bytea field you will receive a stream when fetching the PDO. To process the data any further first transform the stream to usual data like this: $stream = $row['content']; rewind($stream); $data=stream_get_contents($stream);

提交回复
热议问题