Skip to content
Advertisement

How can I encode/decode to base64?

I want to encode/decode my Image with base64:

  $imageEncoded = base64_encode($image);
  $imageDecoded = imagecreatefromstring(base64_decode($imageEncoded));

But it is not correctly decoded

Advertisement

Answer

You don’t have to use imagecreatefromstring in your code. You can encode/decode with php base64 functions.

$imageEncoded = base64_encode($your_image);
$imageDecoded = base64_decode($imageEncoded);
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement