Here's some additional info. Found this on PHP.net:
Number 1:
If you generate and display a temporary image, you can not delete (unlink) it immediately in the same script. Even though you generate the code to display it, the image is really displayed only in the browser, after your script is finished... hm, probably obvious but possibly helpful to people like me 🙂
What does this mean, exactly? It's not displaying in the browser only on my end! :)
Number 2:
You cant unlink() a file that you opened in the same script before with fopen().
If you try to unlink a file opened with fopen() earlier you will get a "permission denied" php error - thats because the file was locked by fopen(), close the file pointer and then unlink() the file!
This took me hours because I didnt know fopen() locks the file.
So, my revised code (still not working quite right):
$handle = fopen($file, "r");
echo "<B>Thumbnail preview:</B><BR>";
$new_w=100;
$new_h=100;
$tmpfname = tempnam ("$dir", "$userfile_name");
//To constrain images to width=200, but not scale up smaller images
system("convert $file -resize \"200>\" \"$tmpfname\".jpg");
echo "<img src=\"$tmpfname.jpg\"><br>";
fclose($handle);
unlink(trim($tmpfname));
Thanks,
Eve