Kin*_*nch 59
使用第三个参数mkdir():
recursive允许创建路径名中指定的嵌套目录.默认为FALSE.
$path = '/path/to/folder/with/subdirectory';
mkdir($path, 0777, true);
Run Code Online (Sandbox Code Playgroud)
小智 5
recursive 允许创建在路径名中指定的嵌套目录。但对我不起作用!!因为这就是我想出的!!它工作得非常完美!!
$upPath = "../uploads/RS/2014/BOI/002"; // full path
$tags = explode('/' ,$upPath); // explode the full path
$mkDir = "";
foreach($tags as $folder) {
$mkDir = $mkDir . $folder ."/"; // make one directory join one other for the nest directory to make
echo '"'.$mkDir.'"<br/>'; // this will show the directory created each time
if(!is_dir($mkDir)) { // check if directory exist or not
mkdir($mkDir, 0777); // if not exist then make the directory
}
}
Run Code Online (Sandbox Code Playgroud)