3

http://oep.esy.es/testimage.php as you can see here, that is the output of png image. image is here:

http://oep.esy.es/images/object/1365-50.png

My code is that:

$homepage = file_get_contents("http://oep.esy.es/images/object/1365-50.png");
echo $homepage;

I want to store as byte array because in Android client, I need that image so I need to pull it. Is it bad method?

But when I try to show image, it doesnot show:

echo "<img src='data:image/png;base64, $homepage' />";

I also tried jpeg but did not work.

1 Answer 1

4

You're missing the base64_encode() function, something like:

$path = file_get_contents("http://oep.esy.es/images/object/1365-50.png");
echo "<img src='data:image/png;base64, " . base64_encode($path) ."'/>";
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.