...

View Full Version : How To Make Directory



eshban
06-08-2005, 12:41 PM
Hi,

I am making a directory by using a builtin PHP function "mkdir".

i am using this code:

mkdir("txt");

But how can i check that, is this directory is already created or not.If this directory is already created then it just shows a message "directory already created", and otherwise it will create this directory.

Kindly help me that how can i write this code.

delinear
06-08-2005, 12:51 PM
Something like this:


$dir = 'directory_name';
$path = '/path/to/directory/';

if(file_exists($path . $dir) && is_dir($path . $dir)) {
echo 'Sorry, a directory with that name already exists.';
} else {
// your code to create the directory
}



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum