界面语言:简体中文 软件大小:未知
文件类型:.exe 发布时间:2010-09-01
很多时候我们要复制文件夹同步或备份
!php很方便就做到!请看教程
- <?
- set_time_limit(0); /* 如果文件或子目录比较多的,最好加上这句 */
- $root_dir = $_SERVER['DOCUMENT_ROOT'];
- /* 修改下面两处的变量,换成自己的 */
- $f_source = '/phpzy'; /* 源目录: 相对于文档根目录的路径 */
- $f_dest = '/phpzy2/test'; /* 目标目录: 相对于文档根目录的路径 */
- $f_source = $root_dir.$f_source;
- echo $f_dest = $root_dir.$f_dest;
- dirCopy($f_source,$f_dest); /* 调用自定义的函数 */
- function dirCopy($source,$dest) {
- static $count = 0;
- static $root;
- $temp_arr = array();
- $count++;
- /* 文件存在不拷贝
- if ($count==1 && file_exists($dest)) {
- return false;
- }
- */
- if ($count==1) {
- $root = $source;
- if (!file_exists($dest)) {
- mkdir($dest,0777);
- }
- } else {
- $dir_src = dirname($source);
- $rela_dir = str_replace($root,'',$dir_src);
- $dir_dst = $dest.$rela_dir;
- if (!file_exists($dir_dst)) {
- mkdir($dir_dst,0777);
- }
- }
- if (is_file($source)) {
- $file_name = str_replace($dir_src,'',$source);
- $file_new = $dir_dst.$file_name;
- copy($source,$file_new);
- // echo "$source-->$file_new <br />"; /* 去掉前面的注释,可以查看具体过程 */
- } elseif (is_dir($source)) {
- $temp_arr = scandir($source);
- array_shift($temp_arr);
- array_shift($temp_arr);
- foreach ($temp_arr as $value) {
- $temp_path = $source.'/'.$value;
- dirCopy($temp_path,$dest);
- }
- } else {
- return true;
- }
- }
- ?>
温馨提示:
①:如果您发现有php拷贝文件夹及文件夹文件免费下载,而绿色php资源未能索引到,请及时通知我们。您的热心是对绿色php资源网最大的支持。
②:php拷贝文件夹及文件夹文件是优秀的免费的资源,索引php拷贝文件夹及文件夹文件链接到本站只是为了让您方便下载。支持作者请购买正版。
③:本网站是一个免费绿色php资源下载站,仅提供php拷贝文件夹及文件夹文件资源免费下载,若有下载php拷贝文件夹及文件夹文件资源者请24小时后自行删除。
④:如果作品浏览,或对php拷贝文件夹及文件夹文件作品内容、版权等方面有质疑,或对绿色php资源网有意见建议请及时反馈给我们,以便我们及时处理!