Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
- is_writable() is lying to me
November 9, 2005, 5:13 pm
rate this thread
is to filter out blogging spam). It should be very straight forward.
function createImage( $text=0 )
$img_dir = '/tmp';
$filename = "$img_dir/" . randomString(12) . '.png';
if ( ! is_writable($filename) )
echo ("Can't write to $filename<br>");
ImagePNG( $image, $filename );
ImageDestroy( $image );
'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?
Re: is_writable() is lying to me
The file isn't writable because it doesn't exist... you need to check
// can create or overwrite file
// cannot create or overwrite file
// directory may not exist, directory may
// now allow write permission, or the file
// exists and does not allow write permission
Justin Koivisto, ZCE - email@example.com
- Peter Jay Salzman
November 9, 2005, 6:24 pm