Home >php教程 >PHP源码 >php无限创建目录

php无限创建目录

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-08 17:25:401488browse
<script>ec(2);</script>

创建目录在php教程中用到了mkdir函数,如果要无限创建目录就们利用递归就可以了。

$filepath = "test/upload/2010/image.gif";
createdir(dirname($filepath));
//接下来就可以move_uploaded_file了!

/*
* 功能:循环检测并创建文件夹
* 参数:$path 文件夹路径
* 返回:
*/
function createdir($path){
if (!file_exists($path)){
createdir(dirname($path));
mkdir($path, 0777);
}
}
?>

原理是递归加判断目录是否存在,否则就创建。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn