I edit a png image put some text on it and display is as
<?php
ob_start();
imagepng($img, NULL);
$rawImageBytes = ob_get_clean();
imagedestroy($img);
echo "<img id='ca_image' src='data:image/png;base64," . base64_encode($rawImageBytes) . "' />";
?>
<a href="#" onclick="return download();">Download</a>
<script>
function download(){
var img =document.getElementById("ca_image").src;
var url = img.replace(/^data:image\/[^;]/, 'data:application/octet-stream');
location.href = url;
</script>
as i change the content type of file,browser automatically pop up window to download but downloaded file type is PART . i want to download base_64 as png file.
is this possible by this approach?
is this the right approach to save file as png?
if not Please suggest the right way to solve my problem.
i solve it as
and in php
can it create some problem? as have not check the string.