Results 1 to 5 of 5

Thread: replace folder

  1. #1

    Thread Starter
    Lively Member maki's Avatar
    Join Date
    Mar 2006
    Location
    Greece
    Posts
    82

    replace folder

    Hello,

    i am using the following line of code to create new directories for every course in a .xml file

    Code:
    mkdir("C:\arxeio\-Lesson id-$cid", 0700);
    once the directory is beeing created how can i replace it in order not to get the following warning

    Code:
    Warning: mkdir() [function.mkdir]: File exists in C:\xampp\htdocs\thalis\arxeiothetisis.php on line 33
    I am working with PHP5

    Thanks

  2. #2

  3. #3
    PowerPoster
    Join Date
    Sep 2003
    Location
    Edmonton, AB, Canada
    Posts
    2,629

    Re: replace folder

    if the directory already exists, why do you want to replace it? just check to see if it exists, and if it does, skip it.

  4. #4

    Thread Starter
    Lively Member maki's Avatar
    Join Date
    Mar 2006
    Location
    Greece
    Posts
    82

    Re: replace folder

    How can i skip it?

  5. #5
    PowerPoster
    Join Date
    Sep 2003
    Location
    Edmonton, AB, Canada
    Posts
    2,629

    Re: replace folder

    in your loop you just need to check if it exists before you create it, then just don't call mkdir() if it's already there.. you can use is_dir() to check whether or not a directory already exists. it will return false if it doesn't exist or if it isn't a directory. it will return true if it does exist and is a directory.

Posting Permissions

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



Click Here to Expand Forum to Full Width