PHP & GD open image file error
| From: | Ken Whitmore | Date: | Fri, 22 Dec 2000 18:43:42 +0000 |
| Subject: | PHP & GD open image file error | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-31607@lists.php.net to get a copy of this message | ||
I'm just starting out with GD in PHP and have a problem.
I've created a file named drawimage.php with the contents listed at the end
of this message.
When I attempt to browse the page in MSIE, (haven't tried it on any other
yet,) an error message appears in the browser window and a missing image
icon shows below the message.
The error message is as follows:
Warning: imagegif: unable to open 'out.gif' for writing in
/home/httpd/html/wow/pedigree/php/drawimage.php on line 8
I've checked the server with phpinfo(); and it shows that GD is enabled and
GIF support is also.
The directory "dynamic_images" is set for drwxrw-rw- (to avoid somebody
putting something executable in there and executing it). Assuming php is
using "nobody" because it's being called by Apache, which is set for
"nobody", what could be the problem here? (I'm assuming, because I haven't
checked inside PHP for the user yet, but my Apache definitely uses
"nobody".)
============================================================================
=====
PHP File Listing
============================================================================
=====
<?php
// File: drawimage.php
Header("Content-type: image/gif"); // tell user agent to receive a gif image
$im = ImageCreate(100,100); // Create the image buffer
$black = ImageColorAllocate($im,0,0,0); // Create black color
$white = ImageColorAllocate($im,255,255,255); // Create white color
ImageLine($im,0,0,99,99); // Draw a diagonal line
ImageGIF($im,"dynamic_images/out.gif"); // Create and write GIF file. (THIS
LINE GETS THE ERROR!)
ImageDestroy($im); // Destroy image buffer
?>
<HTML>
<HEAD>
<TITLE>Test GD</TITLE>
</HEAD>
<BODY>
<IMG SRC="dynamic_images/out.gif">
</BODY>
</HTML>