|
Posted by Peter on 09/27/33 11:31
Very perplexing. This function creates a png image of a random string (this
is to filter out blogging spam). It should be very straight forward.
function createImage( $text=0 )
{
$img_dir = '/tmp';
(snip!)
$filename = "$img_dir/" . randomString(12) . '.png';
if ( ! is_writable($filename) )
echo ("Can't write to $filename<br>");
ImagePNG( $image, $filename );
ImageDestroy( $image );
return array(
'filename' => $filename,
'passkey' => $text
);
}
When I call this function, it prints on the webpage, e.g.
Can't write to /tmp/TsP1gTUNwAOyQ.png
However, that file clearly exists:
$ ll /tmp/TsP1gTUNwAOyQ.png
-rw-r--r-- www-data www-data 200 2005-11-09 /tmp/TsP1gTUNwAOyQ.png
How can is_writable() be wrong?
In related wierdness, I use this function like so:
$retval = createImage();
$filename = $retval['filename'];
$passkey = $retval['passkey'];
echo "<img src=\"$filename\" />";
But the image doesn't show up in the browser. When I look at the page
source, the statement is there and looks correct:
<img src="/tmp/c2GfviA4r4b47.png" />
and I can even view the image with xv and gimp, however, the image is simply
not on the webpage.
I strongly suspect that these two oddities are related, but I'm running out
of ideas. Anyone have any suggestions?
Thanks,
Pete
[Back to original message]
|