In PHP 4.4.x, the GD functions imagepng() and imagejpeg() fail to create new files , even if the folder permissions are correctly set. If the file is created with 'touch' beforehand, the function will succeed and write the image data to the file. The error is associated with the open_basedir restriction, and does only occur if it is turned on. Reproducible: Always Steps to Reproduce: 1. Create a PHP file "test.php" containing just these lines: <?php $img = imagecreate(10,10); $col = imagecolorallocate($img,0,0,0); imagepng($img, "test.png"); ?> 2. Make sure the folder permissions are set correctly. 3. Open the script in a browser. Actual Results: You will encounter the following error: Warning: imagepng(): Unable to access test.png in /folder/to/test.php on line 4 Warning: imagepng(): Invalid filename 'test.png' in /folder/to/test.php on line 4 The image file will not be created. Expected Results: The image file should be created without any error message. This does only affect the Apache SAPI of PHP with open_basedir set.
Created attachment 74810 [details, diff] Patch containing CVS fixes in PHP 4.4.2 to fix the described problem This patch fixes the addressed issue by adding a new macro to check the open_basedir restrictions. The patch is actually a diff between the current 4.4.1 release and the latest stable CVS snapshot.
After additional testing, I must correct that this bug is dependent on the safe_mode flag, which must be turned on in order to reproduce the described behaviour. open_basedir does not affect this bug, if the paths and permissions are set correctly.
The patch you attached is part of the updates the new dev-lang/php-4.4.1-r3 includes, so this then should fix your GD safe_mode/open_basedir issues, try that and reopen if it doesn't work. Best regards, CHTEKK.