循环创建目录方法
这个会生成image.gif目录
$filepath = "test/upload/2010/image.gif";
mk_dir($filepath);
// 循环创建目录
function mk_dir($dir, $mode = 0755)
{
if (is_dir($dir) || @mkdir($dir,$mode)) return true;
if (!mk_dir(dirname($dir),$mode)) return false;
return @mkdir($dir,$mode);
}
第二种方法:
$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