//is_writeable 函数不准确
function mkdir_p($target)
{
$parentDir = dirname($target);
if( $parentDir==$target ){ echo "创建目录失败 "; return false; } //$parentDir = $target
if (file_exists($target))
{
if (!is_dir($target)) return false;
elseif(!is_writeable($target)) { echo "创建目录失败 $target 目录不可写"; return false; }
elseif(@mkdir($target."/abclafdsaf89342432432932098")) { rmdir($target."/abclafdsaf89342432432932098"); return true; }
else { echo "创建目录失败 $target 目录不可写"; return false; }
}
if ( @mkdir($target, 0777 ) ) return true;
if( mkdir_p($parentDir,$mode) ) return mkdir_p($target,$mode);
}
function mkdir_p($target)
{
$parentDir = dirname($target);
if( $parentDir==$target ){ echo "创建目录失败 "; return false; } //$parentDir = $target
if (file_exists($target))
{
if (!is_dir($target)) return false;
elseif(!is_writeable($target)) { echo "创建目录失败 $target 目录不可写"; return false; }
elseif(@mkdir($target."/abclafdsaf89342432432932098")) { rmdir($target."/abclafdsaf89342432432932098"); return true; }
else { echo "创建目录失败 $target 目录不可写"; return false; }
}
if ( @mkdir($target, 0777 ) ) return true;
if( mkdir_p($parentDir,$mode) ) return mkdir_p($target,$mode);
}