这是我的代码:
$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.'; }
我想将以这种方式生成的图像保存到目录中.我该如何做?
这是imagepng的正确语法:
imagepng($im,"/path/where/you/want/save/the/png.png");
根据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.