Results 1 to 4 of 4

Thread: file permissions

  1. #1
    Join Date
    Dec 2004
    Location
    Colorado USA
    Posts
    11

    Default file permissions

    when i try to write to a file, it doesnt work
    here is the code that i am using
    Code:
    <?php
    $filename = 'iplog.txt';
    $somecontent = $_SERVER[REMOTE_ADDR];
    
    // Let's make sure the file exists and is writable first.
    if (is_writable($filename)) {
    
       // In our example we're opening $filename in append mode.
       // The file pointer is at the bottom of the file hence 
       // that's where $somecontent will go when we fwrite() it.
       if (!$handle = fopen($filename, 'a')) {
             echo "Cannot open file ($filename)";
             exit;
       }
    
       // Write $somecontent to our opened file.
       if (fwrite($handle, $somecontent) === FALSE) {
           echo "Cannot write to file ($filename)";
           exit;
       }
       
       echo "Success, wrote ($somecontent) to file ($filename)";
       
       fclose($handle);
    
    } else {
       echo "The file $filename is not writable";
    }
    ?>
    what i am trying to do is write the ip address of the visitor to the site
    the output is that the file iplog.txt is not writable
    how do i get the file to be writable?

  2. #2
    Join Date
    Jan 2005
    Location
    Saskatchewan, Canada
    Posts
    14

    Default

    I suspect it would be using CHMOD with the files in question... maybe just the file containing the IP writing code.

  3. #3
    Join Date
    Sep 2005
    Location
    bhubaneswar
    Posts
    58

    Default Re: file permissions

    dear friend

    check the file permission of the file you are trying to write on it .check the CHMOD and make sure it is set to 777 .


    :oops: thanks

  4. #4
    Join Date
    May 2005
    Posts
    211

    Default

    755 will suffice, you dont have to do 777. For further reference check a book on LINUX/UNIX

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •