Web Analytics Made Easy -
StatCounter mkdir - CodingForum

Announcement

Collapse
No announcement yet.

mkdir

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • mkdir

    The snip on the php manual on mkdir
    PHP Code:
    mkdir("/path/to/my/dir"0700); 
    shows (to me) that you can create multiple mutilevel directories (path/to/my/dir) once. This however doesnt seem to work. When I tried a

    stuff like that, i get a file doesnt exist error. So i had to create a work around - exploded d dirname i want to create to an array, loop through

    and make the directories. Like this
    PHP Code:
    $dir "path/to/my/dir";
    $dirarr explode("/"$dir);
    foreach(
    $dirarr as $v){
        if(!empty(
    $v)){
                              
    //make the directory
            
    @mkdir($v0775);
            
    //change current directory to new dir created
            
    chdir($v);
            
    //keep in mind how deep we are going into the directories
            //we will sure need to get out
            
    $basedir .= "../";
        }
    }
    //come back to the directory we were before (our real working dir)
    chdir($basedir); 
    This kinda look too complex, though it works. So i was just wondering if i didnt waste my time writing the work around afterall.

  • #2
    No you did good, mkdir("/path/to/my/dir", 0700); assumes that `/path/to/my` already exists.
    resistance is...

    MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)

    Comment

    Working...
    X