How to save an image created from imagecreatefromstring() function?
php
Solution
This is the correct syntax for `imagepng`:
imagepng($im, "/path/where/you/want/save/the/png.png");
According to the PHP manual:
bool imagepng ( resource $image [, string $filename [, int $quality [, int $filters ]]] )
filename - The path to save the file to.
If not set or NULL, the raw image stream will be outputted directly.
Problem
Here is my code: ``` $data = 'iVBORw0KGgoAAAANSUhEUgAAABwAAAASCAMAAAB/2U7WAAAABl' . 'BMVEUAAAD///+l2Z/dAAAASUlEQVR4XqWQUQoAIAxC2/0vXZDr' . 'EX4IJTRkb7lobNUStXsB0jIXIAMSsQnWlsV+wULF4Avk9fLq2r' . '8a5HSE35Q3eO2XP1A1wQkZSgETvDtKdQAAAABJRU5ErkJggg=='; $data = base64_decode($data); $im = imagecreatefromstring($data); if ($im !== false) { header('Content-Type: image/png'); imagepng($im); imagedestroy($im); } else { echo 'An error occurred.'; } ``` I'd like to save the image generated this way to a directory. How do I do this?