I am trying to make the profile view of user using image from byte array. I have successfully rendered the image, but I have problem including the image with other profile content, because of the header('Content-Type: image/png')
which takes the whole file as an image. How to resolve this problem?
$myArray = implode('', array_map(function($e) {
return pack("C*", $e);
}, $image));
if (substr($myArray, 0, 4) == "\x89PNG") header('Content-Type: image/png');
else if (substr($myArray, 0, 2) == "\xFF\xD8") header('Content-Type: image/jpeg');
else if (substr($myArray, 0, 4) == "GIF8") header('Content-Type: image/gif');
echo $myArray;