3

Using Java SDK i have JPEG byte array. Now using PHP i need to show that byte array into JPEG picture using tag.

How can i convert byte array to readable JPEG? Tried this but its not showing the picture at all.

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

EDIT:

I have tried $byteArray = base64_encode($byteArray); but that is not working.

3
  • try php.net/manual/en/function.base64-encode.php Commented May 27, 2015 at 7:50
  • Tried this $byteArray = base64_encode($byteArray); but no image showing still. Commented May 27, 2015 at 7:56
  • This is not working too: String imgString = Base64.encodeToString(getBytesFromBitmap(someImg), Base64.NO_WRAP); Commented May 27, 2015 at 8:11

1 Answer 1

0

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

Sign up to request clarification or add additional context in comments.

1 Comment

This is not for Android. this is not working String imgString = Base64.encodeToString(getBytesFromBitmap(someImg), Base64.NO_WRAP);