I need to transform a BLOB file that comes from a MYSQL database to the Image type, to use on my site, I need to do the conversion using PHP, when I use the image in BLOB format, it goes to the whole site in binary .
I need to transform a BLOB file that comes from a MYSQL database to the Image type, to use on my site, I need to do the conversion using PHP, when I use the image in BLOB format, it goes to the whole site in binary .
There are two ways, one is to save the binary on file (which is not interesting) and another is to add to the src
of the tag img
stating that it is a binary. To do this, simply add data:image/jpeg;base64,
followed by binary code.
That is:
<img src="data:image/jpeg;base64,<?= base64_encode($binary) ?>" />
Depending on how you saved (in rare cases) base64_encode
can be omitted