georgeocrawford
Technical User
Hi - wonder if someone can help?
I have written a script which takes a text input, processes it and displays the results using the
function. All works perfectly.
The only problem is that each time I run the script (a simple form which posts back into the same page) and the image is displayed, the browser shows its cached version of the image.
Clicking refresh in the browser loads the new image, but this is obviously not a very professional soultion!
I need some help with saving the png as a temporary file. I have tried this idea:
...which works great, and creates uniquely named images like 51386.png in the images folder.
However, to tidy things up I obviously want to delete the previous image before doing this, to save disk space. So:
However, now I get this error:
This is, I guess, a permissions problem. I have tried adding
into the
loop, but that fails too.
What am I doing wrong? Am I on the wrong track - Is there an easier way to save a GD output to a temporary file which can be used in a html page?
Thanks for any help!
I have written a script which takes a text input, processes it and displays the results using the
Code:
imagepng($im)
The only problem is that each time I run the script (a simple form which posts back into the same page) and the image is displayed, the browser shows its cached version of the image.
Clicking refresh in the browser loads the new image, but this is obviously not a very professional soultion!
I need some help with saving the png as a temporary file. I have tried this idea:
Code:
srand(time());
$random = (rand(0, 99999));
$path = "images/$random.png";
$open_file = fopen($path, "a+");
ImagePng($im, $path);
...which works great, and creates uniquely named images like 51386.png in the images folder.
However, to tidy things up I obviously want to delete the previous image before doing this, to save disk space. So:
Code:
$folder = opendir("images");
while ($file = readdir($folder)) {
unlink($file);
}
However, now I get this error:
Code:
Warning: unlink() failed (Operation not permitted)
This is, I guess, a permissions problem. I have tried adding
Code:
chmod($file, 0777)
Code:
while
What am I doing wrong? Am I on the wrong track - Is there an easier way to save a GD output to a temporary file which can be used in a html page?
Thanks for any help!