php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #31059 cannot write to files
Submitted: 2004-12-10 23:22 UTC Modified: 2004-12-11 00:38 UTC
From: gagarin at i-dep dot com Assigned:
Status: Not a bug Package: Filesystem function related
PHP Version: 4.3.9 OS: linux fedora core 3
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: gagarin at i-dep dot com
New email:
PHP Version: OS:

 

 [2004-12-10 23:22 UTC] gagarin at i-dep dot com
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)

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-12-11 00:38 UTC] derick@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions. 

Thank you for your interest in PHP.

.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Jul 03 11:01:34 2025 UTC