Page 1 of 1

php and making folders (mkdir)

Posted: Thu Mar 16, 2006 11:10 pm
by cloudee1
I am able to create one level just fine, but I want to make two! This code creates one folder, but it just won't make that second folder inside the first.

Code: Select all

// Create a folder 
   $pagefolder=$_POST['pagefolder'];
   exec("mkdir $pagefolder"); 

// now place a folder in that folder.
   $url_images = $_POST['url_images'];
   $picfolder  = $pagefolder;
   $picfolder .='/';
   $picfolder .=$url_images;
   exec("mkdir $picfolder"); 
Does anyone know if this is even possible, and if so then how? I am not looking to set permissions or any other fanciness, just plain old folders.

Re:php and making folders (mkdir)

Posted: Thu Mar 16, 2006 11:58 pm
by Warrior
I'm not sure, if anything change directories to the newly created one, create the second folder, then change back to the root folder.

Re:php and making folders (mkdir)

Posted: Sat Mar 18, 2006 5:41 am
by Simon
This should do what you're after:

Code: Select all

mkdir -p firstdir/seconddir/thirddir

Re:php and making folders (mkdir)

Posted: Mon Mar 20, 2006 3:03 am
by bubach
Or you could use php's mkdir() function in wich:
mkdir("test1/test2");
works just fine..