954,568 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

make directory

i created one directory using mkdir.now i want to create another directory inside previous directory.

$uploaddir1 = "resumes/".$_SESSION["uss1"]."/".$uname;
echo $uploaddir1;
if(is_dir($uploaddir1))
{ 
echo "Exists!"; 
} 
else
{ 
echo "Doesn't exist" ;
mkdir($uploaddir1,0777);
print "created"; 
}

output is Doesn't existcreated.but when i open $_SESSION["uss1"] directory the new directory was not exist.

kings
Junior Poster
107 posts since Nov 2007
Reputation Points: 3
Solved Threads: 2
 

Thats strange! check if $uname is empty.

nav33n
Purple hazed!
Moderator
4,465 posts since Nov 2007
Reputation Points: 524
Solved Threads: 356
 

thanks for ur reply.$cname was not exist.i want to know this syntax is correct. $uploaddir1 = "resumes/".$_SESSION["uss1"]."/".$uname;
$_SESSION["uss1"]-this is one directory i created already using mkdir.
$uname=this directory i want to create now.

kings
Junior Poster
107 posts since Nov 2007
Reputation Points: 3
Solved Threads: 2
 

Yep. Its correct. Make sure that none of the variables are empty.

nav33n
Purple hazed!
Moderator
4,465 posts since Nov 2007
Reputation Points: 524
Solved Threads: 356
 

there is no empty variable.i'm getting output is resume/hi/hi1doesn't existcreated.

kings
Junior Poster
107 posts since Nov 2007
Reputation Points: 3
Solved Threads: 2
 

hmm.. When you execute mkdir, check again if that directory exists. ie.,
mkdir($uploaddir1,0777);
if(is_dir($uploaddir1))
{
echo "Exists!";
}
else
{
echo "Doesn't exist" ;
}

nav33n
Purple hazed!
Moderator
4,465 posts since Nov 2007
Reputation Points: 524
Solved Threads: 356
 
$uploaddir1 = "resumes/".$_SESSION["uss1"]."/".$uname;
echo $uploaddir1;
if(is_dir($uploaddir1))
{ 
echo "Exists!"; 
} 
else
{ 
echo "Doesn't exist" ;
mkdir($uploaddir1,0777);
print "created"; 
}

No.this is my whole coding.for this i'm getting output resumes/hi/hi1doesntexistcreated. i did all the checks.but directory was not created in the site.

kings
Junior Poster
107 posts since Nov 2007
Reputation Points: 3
Solved Threads: 2
 

No dude. You are checking before creating the directory. Do the same after you create the directory. That way, you will know if it really created the directory or not.

nav33n
Purple hazed!
Moderator
4,465 posts since Nov 2007
Reputation Points: 524
Solved Threads: 356
 

thank you.my code was not creating a directory really..

kings
Junior Poster
107 posts since Nov 2007
Reputation Points: 3
Solved Threads: 2
 

hmm.. Strange.. It didn't throw any error !

nav33n
Purple hazed!
Moderator
4,465 posts since Nov 2007
Reputation Points: 524
Solved Threads: 356
 

hi
i just view your code so i have a one idea

<?php
$path = dirname( __FILE__ );
$uploaddir1 = $path."resumes/".$_SESSION["uss1"]."/".$uname;
?>

try this b'cos $path give you current directory path
and also make sure that parents directory have right to create child directory

Thanks

Tulsa
Junior Poster in Training
77 posts since May 2009
Reputation Points: 13
Solved Threads: 15
 

Will you people PLEASE read the date on the last post before you bump year old threads, this is getting really, really annoying and it's been happening a lot lately.

ShawnCplus
Code Monkey
Team Colleague
1,583 posts since Apr 2005
Reputation Points: 526
Solved Threads: 268
 

Hi,
I have created the folder for using the following code
<?php
define("Folder","year");
$folders = Folder."/".date("Y")."/".strtolower(date("M",strtotime("May")).date("y",strtotime("2011")));
if(!is_dir($folders)){
$dir = explode("/",$folders);
$dir_folder = "";
foreach($dir as $d){
$dir_folder .= $d ."/";
if(!is_dir($dir_folder)){
mkdir($dir_folder,0777);
echo "ok";
}

}
}
else{
echo "no";
}
?>

Output: year/2011/may11

pandikamal
Newbie Poster
1 post since Sep 2009
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You