Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3

Thread: fwrite - chmod

  1. #1
    New Coder
    Join Date
    Sep 2006
    Posts
    72
    Thanks
    3
    Thanked 0 Times in 0 Posts

    fwrite - chmod

    A standard file write routine - generating the file $fname on the first run.

    $fh = fopen($fname, 'w');
    fwrite($fh,$data);
    fclose($fh);

    On the current server the file, $fname, is written with permission and status:
    -rw-r--r-- www-data
    So... trying to later write to the file doesn't work.
    Being www-data it resists standard fTP chmod command.
    It also fails:
    chmod("$fname", 0666);

    Any suggestions or comments here would be most welcome.

    thanks

  • #2
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    I'm a little confused about your question. What are you trying to do? Just use fopen again to write to the file again. To write to a directory the permissions need to be set to 770 or 777. I think 770 is the safer method.
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #3
    New Coder
    Join Date
    Sep 2006
    Posts
    72
    Thanks
    3
    Thanked 0 Times in 0 Posts

    got it sussed

    I now see that my php chmod script was giving errors - but only for directories.

    Easy to test for is_dir and skip.

    Yes, 770 is enough - and adds a bit of extra security.

    thanks


  •  

    Posting Permissions

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