PDA

Click to See Complete Forum and Search --> : replace folder


maki
Mar 15th, 2007, 10:46 AM
Hello,

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

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

Warning: mkdir() [function.mkdir]: File exists in C:\xampp\htdocs\thalis\arxeiothetisis.php on line 33


I am working with PHP5

Thanks

MartinLiss
Mar 15th, 2007, 10:48 AM
Moved since Forum Feedback is only meant for questions and comments about VB Forums itself.

kows
Mar 15th, 2007, 11:03 AM
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.

maki
Mar 15th, 2007, 12:07 PM
How can i skip it?:confused:

kows
Mar 15th, 2007, 01:22 PM
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() (http://ca3.php.net/manual/en/function.is-dir.php) 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.