我的代码在这里:
if (isset($_POST['points'])) {
$points = $_POST['points'];
$image = imagecreate(200, 200);
$white = imagecolorallocate($image, 255, 255, 255);
$black = imagecolorallocate($image, 0, 0, 0);
... polyline path drawing here...?
imageline($image, 10, 10, 10, 190, $black);
header('Content-Type: image/png');
imagepng($image);
imagedestroy($image);
... how to save it to the server?
}
感谢。
答案 0 :(得分:1)
要保存图像,您可以使用imagepng
的第二个(可选)参数:
imagepng($image, 'saved.png');
对于折线,您将在循环内调用imageline
- 具体取决于您的$points
值的结构。
答案 1 :(得分:0)
要将图像动态保存到服务器,请使用图像功能的第二个参数指定位置和文件名。
//specify the path on the server where you want to save the image
$path_image = 'saved-example.png';
imagepng($image, $path_image);
imagepng($image);
imagedestroy($image);
图像将保存到该路径。