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

php无限创建目录

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-08 17:25:40
Original
1487 people have browsed it
<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);
}
}
?>

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

Related labels:
Statement of this Website
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
Latest Issues
access path
From 1970-01-01 08:00:00
0
0
0
Static resource path usage
From 1970-01-01 08:00:00
0
0
0
objective-c - header search path
From 1970-01-01 08:00:00
0
0
0
javascript - vue src path problem
From 1970-01-01 08:00:00
0
0
0
php move_uploaded_file() path parameter usage
From 1970-01-01 08:00:00
0
0
0
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template