I got the same error, but if I try this:
echo '<img src="'.$data.'"/>';
Then the image is displayed ...
This does not work in the shell:
echo 'iVBORw0KGgoAAAANSUhEUgAAABwAAAASAQMAAAByySynAAAABlBMVEUAAAD///+l2Z/dAAAAP0lEQVQImWNgPm9gwAAmbM4bH4AQzAdAYiDC/rzxByTi/+f/cI' | base64 -d - >file.png
I got base64: invalid entry.
If I add "=":
echo 'iVBORw0KGgoAAAANSUhEUgAAABwAAAASAQMAAAByySynAAAABlBMVEUAAAD///+l2Z/dAAAAP0lEQVQImWNgPm9gwAAmbM4bH4AQzAdAYiDC/rzxByTi/+f/cIL=' | base64 -d - >file.png
Then itβs good. But also bad with imagecreatefromstring ().
Could you tell us how you got base64 encoded content in javascript?
See this comment: http://www.php.net/manual/en/function.base64-decode.php#102113
Edit : This code works ...
<?php $data = 'iVBORw0KGgoAAAANSUhEUgAAABwAAAASAQMAAAByySynAAAABlBMVEUAAAD///+l2Z/dAAAAP0lEQVQImWNgPm9gwAAmbM4bH4AQzAdAYiDC/rzxByTi/+f/cIL'; $data = base64_decode($data); header('Content-Type: image/png'); echo $data; ?>
source share