mkdir(dechex($a),0755); for ($b=0;$b<=15;$b++) { mkdir(dechex($a).'/'.dechex($b),0755); for ($c=0;$c<=15;$c++) { mkdir(dechex($a).'/'.dechex($b).'/'.dechex($c),0755); } }}
since PHP 5, setting the recursive flag (which currently has no notes in the manual entry) will allow you to create nested directories in the same way as Windows / Linux mkdir -p, so long as the webserver has permissions to write in the root directory of the path specified eg:<?php mkdir ("./newdir1/newdir2/newdir3/", 0755, true); // Returns TRUE if you have permission to write to the current directory // and creates nested directories with permissionsrwxr-xr-x ?>是可以的,不过版本要新的
$path1="F:/wenjian/wenjian/wenjian"; function createFolder($path) //自定义的创建文件夹的函数 { if (!file_exists($path)) //如果文件夹不存在 { createFolder(dirname($path)); //递归创建 //取得最后一个文件夹的全路径返回开始的地方 mkdir($path, 0777);//创建并写文件 } } createFolder($path1);这样就建立了多层目录很方便啊
一次建立a,b,c三个目录,有成的吗?
使用绝对路径有成功的吗?
读取目录列表-〉判断是否是目录-〉如果是文件,跳过
-〉如果是目录,递归一次,再判断。
怎么都不去看手册~全部都有写啊 XDhttp://cn.php.net/mkdir
{
$arrDir = explode('/', $dir);
$curDir = ".";
if(is_array($arrDir))
{
foreach($arrDir as $key=>$value)
{
$curDir = $curDir . "/" .$value;
if(is_dir($curDir))
{
continue;
}
else
{
mkdir($curDir);
}
}
}
return;
}linux下用 system("mkdir -p /a/b/c");吧,这个更实用一些.
害得自已写递归函数!见过别人说可以的,看来手册还得好好看!
function createFolder($path){
if (!file_exists($path)){
createFolder(dirname($path));
mkdir($path, 0711);
}
}这个网上写的,还不错
[code=BatchFile]0 ------ 0
1 1
2 2 -------- 0
3 3 1
4 ... 2
5 3
6 ...
7
[....]
e
f[/code]代码:for ($a=0;$a<=15;$a++) {
mkdir(dechex($a),0755); for ($b=0;$b<=15;$b++) { mkdir(dechex($a).'/'.dechex($b),0755); for ($c=0;$c<=15;$c++) { mkdir(dechex($a).'/'.dechex($b).'/'.dechex($c),0755); } }}
eg:<?php
mkdir ("./newdir1/newdir2/newdir3/", 0755, true); // Returns TRUE if you have permission to write to the current directory
// and creates nested directories with permissionsrwxr-xr-x
?>是可以的,不过版本要新的
$path1="F:/wenjian/wenjian/wenjian";
function createFolder($path) //自定义的创建文件夹的函数
{
if (!file_exists($path)) //如果文件夹不存在
{
createFolder(dirname($path)); //递归创建 //取得最后一个文件夹的全路径返回开始的地方
mkdir($path, 0777);//创建并写文件
}
}
createFolder($path1);这样就建立了多层目录很方便啊
我记得可以这样用了???