Can anyone help me with the code to save the image generated on the fly, I can always do right click and save picture, but it needs to be done in the program.
The below program generates a random number and makes an image out of it and displays it. However I want to save the generated image, preferably with the same random it generates or simply the name 00001.png thru 10000.png etc
I can save a copy this way, but I must have a copy already saved by that name for it to work. I guess it saves over the old one.
ImagePNG($im, "test.png");
The below works fine, but it is on screen and is not saved.
I want to save each image automatically under a sequential name as the images are generated.
ImagePNG($im);
As you can see, if the old image is on disk, it writes over the old and I have a new on the fly image saved, but the test.png must be on the server for this to work.
<img src="test.png"><br>
Someone please help me out.
<?php
header("Content-type: image/png");
$new_string;
session_register('new_string');
$im = ImageCreate(60, 20);
$white = ImageColorAllocate($im, 255, 255, 255);
$black = ImageColorAllocate($im, 0, 0, 0);
srand((double)microtime()*1000000);
$string = md5(rand(0,9999));
$new_string = substr($string, 17, 4);
print $new_string;
ImageFill($im, 0, 0, $white);
ImageString($im, 8, 12, 3, $new_string, $black);
// ImagePNG($im, "test.png");
ImagePNG($im);
ImageDestroy($im);
?>
<br><br>
<img src="test.png"><br>
Thanks
Tom