0
I have this code below, where decodes a picture string and displays in the browser, but I can’t save the decoded image with a random name and save to disk.
$string = 'iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAYAAADDPmHLAAAgAElEQVR4nNR9d1gU1/f3mdnOLlvobelIEVEEsWPDgokaC7bYYos ........'
$decoded = base64_decode($string);
header("Content-Type: image/png");
echo $decoded;
?>
I have tried using Fopen function without success. Any hints?
Grateful.
Marcos, I’ll just have the string to be converted to image, I still wouldn’t have the path/file.png. In this case, would I have to decode and save this image first? This is my difficulty, because I can convert and show the image on the screen, but I can’t.
– user54154
you want to save the image to the server ?
– Marcos Brinner
Yes, after converting to image, wanted to save the image with a random name and write to disk.
– user54154
right just cahamar this function that I passed you and where you put the file name put uniqid().". png"
– Marcos Brinner
this will generate an image with Randonico id
– Marcos Brinner
I changed the answer copies the function the way it is
– Marcos Brinner
Marcos, thank you for your help/attention. It is returning error in this list fwrite( $ifp, base64_decode( $data ); syntax error, Unexpected ';' . I’ve already checked everything and apparently the syntax is correct.
– user54154
is missing a ) before ; change to fwrite( $ifp, base64_decode( $date ));
– Marcos Brinner
Good worked out. Thank you.
– user54154