php_begins Posted May 23, 2011 Share Posted May 23, 2011 I have problem creating multiple sub-directories inside a single directory using mkdir: mkdir("files/".$lname,0777); mkdir("files/".$lname."/CV",0777); The above command works fine and creates the directory under $last name as files/$lname/CV. But I am unable to create further sub-directories inside $lname. For eg: mkdir("files/".$lname."/Cover", 0777); (This does not create the directory Cover) this is how my code snippet looks like if($result) { mkdir("files/".$lname,0777); mkdir("files/".$lname."/CV",0777); mkdir("files/".$lname."/Cover", 0777); mkdir("files/".$lname."/LOR", 0777); } Quote Link to comment Share on other sites More sharing options...
AbraCadaver Posted May 23, 2011 Share Posted May 23, 2011 You should get errors? error_reporting(E_ALL); ini_set('display_errors', '1'); Quote Link to comment Share on other sites More sharing options...
php_begins Posted May 23, 2011 Author Share Posted May 23, 2011 Warning: mkdir() [function.mkdir]: No such file or directory in /san/www/files/register.php on line 167 It is creating the CV directory, under $lname but does not create the other 2 directories. Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted May 23, 2011 Share Posted May 23, 2011 If you post your whole actual code, someone can probably directly help you with it. You are likely overwriting/clearing/changing the $lname variable. Quote Link to comment Share on other sites More sharing options...
php_begins Posted May 23, 2011 Author Share Posted May 23, 2011 This is my code: //Create INSERT query $qry = "INSERT INTO $tbl_users(email, password, firstname, lastname, middlename, mailingaddress, phone, date, phdinst, researcharea, position) VALUES('$email','$password','$fname','$lname', '$mname', '$address', '$pnumber', '$date', '$inst', '$rarea', '$position')"; $result = @mysql_query($qry); if($result) { error_reporting(E_ALL); ini_set('display_errors', '1'); $oldmask = umask(0); mkdir("/san/www/files/".$position."/".$lname."_".$email,0777); mkdir("san/www/files/".$position."/".$lname."_".$email."/CV", 0777); mkdir("san/www/files/".$position."/".$lname."_".$email."/Cover_letter", 0777); mkdir("san/www/files/".$position."/".$lname."_".$email."/List_of_references", 0777); mkdir("san/www/files/".$position."/".$lname."_".$email."/teaching_statement", 0777); umask($oldmask); } The position directories already exist. Like i mentioned it creates the CV directory inside $lname_email, but it does not create the other mentioned directories. Quote Link to comment Share on other sites More sharing options...
AbraCadaver Posted May 23, 2011 Share Posted May 23, 2011 I don't know why it works with CV, but all of the paths need the root slash /san Quote Link to comment Share on other sites More sharing options...
php_begins Posted May 23, 2011 Author Share Posted May 23, 2011 ahh :-) Thank you so much. It works now! Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted May 23, 2011 Share Posted May 23, 2011 Given the code you just posted, only the first very first one is working and if you have a CV folder present, it is left over from some previous testing. Quote Link to comment Share on other sites More sharing options...
php_begins Posted May 23, 2011 Author Share Posted May 23, 2011 probably that was the case. It's working fine now. Thanks again. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.