cakephp - create new directory inside webroot

Viewed 2730

I want to create a new directory(folder) inside the webroot so i can create/edit files inside that new folder.

My code is:

$path = 'files' . DS . 'pathtofolder';// $folder_name;
$folder = new Folder($path);
if (!is_null($folder->path)) { //this is to verify if created
    echo "Exists";
}
else{
    echo "Doesnt exist";
}

The result is always doesnt exist. And i cant find any created folder inside my cakephp folders.

I tried to change 'files' for 'webroot' but it doesnt work.

Is this the correct code to create a directory?

3 Answers
Related