I have the following code on my php file which is working fine, Its decoding a base64 string and showing that as a image on the webpage, but i want it to save it on a folder too.
<?php
$base = $_POST['encoded'];
$base = base64_decode($base);
$im = imagecreatefromstring($base);
if ($im !== false) {
header('Content-Type: image/png');
imagepng($im);
imagedestroy($im);
}
else {
echo 'An error occurred.';
}
?>
i have already tried the solution described on these links but none of these are worked for me
How to save a PNG image server-side, from a base64 data string
How to create GD Image from base64 encoded jpeg?
what will be the extra line of code which could save this image to a folder