文件夾及文件操作

来源:互联网 发布:淘宝中差评修改 编辑:程序博客网 时间:2024/06/15 11:59
//递归删除文件夹及子文件夹里的文件
//
递归删除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';
0 0