PHP - How to convert a byte array to an image file?

With the Java SDK, I have a JPEG byte array. Now using PHP I need to show that a byte array into a JPEG image using a tag.

How can I convert a byte array to a readable JPEG? Tried this but didn't show the picture at all.

$byteArray = "[A@53d9e469"; //something like this Java generated
$img = "<img src= 'data:image/jpeg;base64, $byteArray' />";
echo ($img);

      

EDIT:

I've tried $ byteArray = base64_encode ($ byteArray); but it doesn't work.

+3


source to share


1 answer


make sure you go from byte array to base 64. see how to convert image to byte array and byte array to base64 String in android?



+1


source







All Articles