From: gagarin at i-dep dot com
Operating system: linux fedora core 3
PHP version: 4.3.9
PHP Bug Type: Filesystem function related
Bug description: cannot write to files
Description:
------------
I cannot open files for writing with fopen. fileperms function on existing
file returns FALSE.
i checked file permissions, turned safe mode off to no avail. the same
script runs on machines with FC1 and php 4.3.8 just fine.
fopen for reading works fine.
I can read/write the same files with perl cgi scrips but not with php
Reproduce code:
---------------
my test script
<?php
$filename = '/var/www/html/test.txt';
$content = "Add this to the file\n";
if (file_write($filename,$content)) echo "Success";
function file_write($filename, &$content) {
if (!$fp = @fopen($filename, "w")) {
echo "Cannot open file ($filename)";
exit;
}
if (fwrite($fp, $content) === FALSE) {
echo "Cannot write to file ($filename)";
exit;
}
if (!fclose($fp)) {
echo "Cannot close file ($filename)";
exit;
}
return true;
}
?>
Expected result:
----------------
Success
Actual result:
--------------
Cannot open file (/var/www/html/test.txt)
--
Edit bug report at http://bugs.php.net/?id=31059&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=31059&r=trysnapshot4
Try a CVS snapshot (php5.0):
http://bugs.php.net/fix.php?id=31059&r=trysnapshot50
Try a CVS snapshot (php5.1):
http://bugs.php.net/fix.php?id=31059&r=trysnapshot51
Fixed in CVS: http://bugs.php.net/fix.php?id=31059&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=31059&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=31059&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=31059&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=31059&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=31059&r=support
Expected behavior: http://bugs.php.net/fix.php?id=31059&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=31059&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=31059&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=31059&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=31059&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=31059&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=31059&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=31059&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=31059&r=float
MySQL Configuration Error: http://bugs.php.net/fix.php?id=31059&r=mysqlcfg