Creating folder using PHP

by MD on 2010/01/23

To create folder with PHP, following code can be used.

// wherever this particular script will be installed
// I want to create a subfolder

// Step 1. I need to know the absolute path to where I am now
// , ie where this script is running from..

$thisdir = getcwd();

// Step 2. From this folder, I want to create a subfolder called
// "myfiles".  Also, I want to try and make this folder
// world-writable (CHMOD 0777). Tell me if success or failure...

if(mkdir($thisdir ."/myfiles" , 0777))
{
   echo "Directory has been created successfully...";
}
else
{
   echo "Failed to create directory...";
}

You may also like:

Leave a Comment

Previous post:

Next post: