View Full Version : How To Make Directory

06-08-2005, 11:41 AM

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

i am using this code:


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.

06-08-2005, 11:51 AM
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