$path='./download/test'; //文件夹路径
mkdir($path); //创建文件夹
delFileUnderDir($path);
mkdir($path); //删除空的文件夹
//删除文件夹下的文件
function delFileUnderDir( $dirName )
{
if ( $handle = opendir( "$dirName" ) ) {
while ( false !== ( $item = readdir( $handle ) ) ) {
if ( $item != "." && $item != ".." ) {
if ( is_dir( "$dirName/$item" ) ) {
delFileUnderDir( "$dirName/$item" );
} else {
if( unlink( "$dirName/$item" ) );
}
}
}
closedir( $handle );
}
}
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!