#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    114
    Rep Power
    15
    I suspect this question has more to do with Linux than with PHP, but here it is: If a file already exists and I chmod 666 file_name then I can fopen("file_name","w") and everything works fine. But if a file doesn't exist and I try to create it with fopen("file_name","w") I get the 'permission denied' problem. I have PHP configured as an apache module so it runs under user:nobody, but even if I chown nobody.nobody directory, I can't get PHP to create new files. So, what do I need to do for this to work?
  2. #2
  3. Banned (not really)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 1999
    Location
    Brussels, Belgium
    Posts
    14,648
    Rep Power
    4493
    I usually have to make the directory permissions 777 in order to allow PHP to create or copy files to that directory. I havnen't found or heard of any other solution.

    ---John Holmes
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2000
    Location
    Newark, DE, USA
    Posts
    39
    Rep Power
    15
    I chown the directory to the same user as my webserver, and chmod the directory to 755, and I can create file w/o any issues. Give it a whirl? If not, try 777. Be aware that this may open security issues for your web server, though.

    ------------------
    ~Chris
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    114
    Rep Power
    15
    Hey, thanks. The chmod 777 did the trick.
  8. #5
  9. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2000
    Posts
    1
    Rep Power
    0
    sorry, little question from a dummie.
    i had the same problem and
    i think the cwwesley solution is better to preserve security.
    But how can i do to know the user as my webserver ?

    thanks
    Francesco
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    114
    Rep Power
    15
    If you're running apache just look in the httpd.conf file. Chances are your server runs as user:nobody and group:nobody.

    [This message has been edited by billyo (edited October 26, 2000).]

Similar Threads

  1. Converting DOC files to PDF files using PHP
    By necrophagous in forum PHP Development
    Replies: 3
    Last Post: February 6th, 2004, 01:36 PM
  2. Creating xml files using php
    By Welshie21 in forum PHP Development
    Replies: 16
    Last Post: January 30th, 2004, 11:56 PM
  3. Can php be used in html files
    By emzyme in forum PHP Development
    Replies: 3
    Last Post: January 29th, 2004, 02:50 PM
  4. Need help creating fixed length file in PHP
    By ecroskey in forum PHP Development
    Replies: 0
    Last Post: January 28th, 2004, 10:31 AM
  5. help with zipping up files with php
    By thindery in forum PHP Development
    Replies: 1
    Last Post: January 21st, 2004, 11:26 PM

IMN logo majestic logo threadwatch logo seochat tools logo