mkdir

Discussion in 'PHP' started by gigamike, Feb 13, 2008.

  1. #1
    Guys,

    i hope you can help me. Im trying to issue a mkdir and it works fine. My problem is that when i create new folder or sub directories inside the generated folder, it cannot or error occur. See sample code.

    $year=date("Y");
    $month=date("m");
    $day=date("d");

    $directory=TEMPORARY."/".$year.$month.$day;

    if(!file_exists($directory)){
    mkdir($directory, 0777);
    chmod($directory, 0777);
    }

    // Create unique folder
    $temp=md5(uniqid(rand(),true));
    if(!file_exists($directory."/".$temp)){
    mkdir($directory."/".$temp, 0777); // Error Here since the owner of parent directory was 33 or nobody
    @chmod($directory."/".$temp, 0777);
    }

    The issue was when i create a folder, the owner and user was 33 or nobody owner. I already tried chgrp and chown to mkdir but doesnt seems to work. I think im missing something with my ownership/group of my script. I dont want to turn off the safe mode just to have a sub directories. Any idea?

    Thanks,

    Mike
     
    gigamike, Feb 13, 2008 IP