文件夾及文件操作

//递归删除文件夹及子文件夹里的文件
//
递归删除add by Helin function deldir($dir_path){ $dir=opendir($dir_path); while($file=readdir($dir)){ if($file!="." && $file!="..") { $fullpath=$dir_path."/".$file; if(!is_dir($fullpath)) {
            unlink($fullpath); } else {
            deldir($fullpath);
          } } }
closedir($dir); rmdir($dir_path); return true; }

 

//獲取文件夾內所有文件的文件名稱:
$dir
= '../xml_popup/'; $handle = opendir($dir."."); $code = ''; while(false !== ($file = readdir($handle)) ){ if($file != '.' && $file != '..'){ $code .= ','.$file; } } closedir($handle); $fp = @fopen('array_code.php',"wb"); fwrite($fp,$code); fclose($fp); echo 'ok';

 

posted @ 2012-07-05 22:49  Vhelin  阅读(163)  评论(0编辑  收藏  举报