mkdir problems

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • fouadk
    New Member
    • Jul 2008
    • 5

    mkdir problems

    hi everyone....

    i am trying to create a folder in my home directory but that ain't working due to permission restriction

    my code looks like the following:
    Code:
    <?php
    $path = "/home/fouad/testing";
    if(mkdir($path,700,TRUE)) {print "success."; }else {print "failure.";}
    ?>
    and my output is the following:
    Code:
     Warning: mkdir() [function.mkdir]: Permission denied in /var/www/test2.php on line 3 
    failure.
    i know it is related to permissions but i dunno how to fix that....

    please help

    thanks in advance
  • pbmods
    Recognized Expert Expert
    • Apr 2007
    • 5821

    #2
    Heya, Fouad.

    Make sure you have write permissions in /home/fouad.

    Comment

    • fouadk
      New Member
      • Jul 2008
      • 5

      #3
      write permissions to which users??? user of php ??? user of apache ????
      which user???

      thanks

      Comment

      • pbmods
        Recognized Expert Expert
        • Apr 2007
        • 5821

        #4
        PHP runs as whatever User/group that Apache does, so as long as the directory is writable to Apache, it will be writable to PHP.

        If Apache can read from the directory, you simply need to add write permissions.

        Try each the following commands in this order until you get it working:
        [code=sh]
        chmod 755 /home/fouad
        chmod 775 /home/fouad
        chmod 777 /home/fouad
        [/code]

        The last one is the least secure, but is guaranteed to work.

        Comment

        Working...