<?php /* * 作用:主用于文件上传后的目录自动生成 * 时间:2006-3-12 * 作者:欣然随风 */ class class_dir { /** * 换算实际路径 */ function dir_path($path) { $adir = explode('/',$path); for($i=0;$idir_path($path); $adir = explode('/',$path); $dirlist = ''; $rootdir = array_shift($adir); if(!file_exists($rootdir)) mkdir($rootdir); foreach($adir as $val) { $dirlist .= "/".$val; $dirpath = $rootdir.$dirlist; if(!file_exists($dirpath)) { mkdir($dirpath); chmod($dirpath,0777); } } } }//class end //测试: $path = "E:/xxx/main/configs/../../../main/upfile/logo/"; $p = new class_dir; $p->dir_mkdirs($path); ?>
php 新建文件 相对路径,PHP转换相对路径,并创建目录
最新推荐文章于 2022-04-11 13:21:15 发布