请教宇凡--关于整个文件夹的拷贝 宇凡: 如果我考虑用ftp的办法(当然我要实现从一台网络主机拷到另一台网络主机),您有没有现成的代码范例。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 首先用FTP的话,php好象是不能实现直接对文件夹的copy的~~另外,如果你是第三方服务器的话~~当然权限必须要有~~你的脚本运行的主机就应该是作为数据交换空间。最后~~咳咳~~由于公司里做类似这样的数据交换都是用Delphi或VC实现的~~~所以我很少用过PHP的FTP函数库~~所以~~5555~~我也不是很熟啦~~所以好多朋友来问ftp的问题我都不敢发言~~真是失败~~:( 好象phpuser.com中有xcopy增强函数的定义,把上面关于文件的拷贝命令换成ftp命令就成了吧??? <? /////THIS CAN MAKE AND COPY FISRT LEVEL DIRETORY AND THEIR FILES function dircopy($old,$new) { //to copy directory & copy files in the FISRT level directory $d=opendir($old); while($file=readdir($d)) {if($file=='.' || $file=='..') echo $file."is a directory<br>"; else { //if its a diretory if(is_dir($file)&& $file!=$new ) {echo "<br>directory $file------------<br>"; $olddir="./".$file; $newdir=$new.$file; if(!is_dir($newdir)) mkdir($newdir,0777); $dd=opendir($olddir); while($filed=readdir($dd)) {if(is_file($olddir."/".$filed)) { //echo "$filed<br>"; $oldfile=$olddir."/".$filed."/"; $newfile=$newdir."/".$filed."/"; $yes=copy($oldfile,$newfile); if($yes) echo $oldfile."copy success!<br>"; else echo $oldfile."copy wrong<br>"; } } } else { //to copy files in root directory echo "begin copy root directory files..........<br>"; if($file!="install.php") {if($file!="sql.php") { $newfile=$new."/".$file; $oldfile=$old."/".$file; $newdir=$new.$file; $yes=copy($oldfile,$newfile); if($yes) echo $file."copy success!<br>"; else echo $file."copy wrong<br>"; } } } } } closedir($d);}//*************************************//***********************function end**************//********************************//*******test below //old is this install file directory $old=".";$new="../fenzhan/";dircopy($old,$new);?> phpuser.com上有代码片段~!自己仔细找找~! old的路径怎么设的?能写的详细些吗,比如要拷贝 c:\test 为什么不自己试写?FTP函数不难,. php怎样把多条件组合查询的结果导出成excel goolge搜索的页面预览是如何实现的 $_session为什么ie中保存汉字乱码,ff,chrome却都正常 这样的数组结构怎么获取$level和$effective的值 php 有多少分奉献多少分:: 按照教科书写了一个创建图片缩略图的函数 执行的时候出错 GG们来看看 php 关于加密解密的一个算法 字符串转数组 Mysql 中,这样的sql不能用吗,为什么总报错啊? 第一次发现这个地方…… 我现在有一个很急的问题,请大家帮我!!! 在php中如何遍历数据库: 帮我看看这个程序段
<?
/////THIS CAN MAKE AND COPY FISRT LEVEL DIRETORY AND THEIR FILES
function dircopy($old,$new)
{
//to copy directory & copy files in the FISRT level directory
$d=opendir($old);
while($file=readdir($d))
{if($file=='.' || $file=='..')
echo $file."is a directory<br>";
else
{
//if its a diretory
if(is_dir($file)&& $file!=$new )
{echo "<br>directory $file------------<br>";
$olddir="./".$file;
$newdir=$new.$file;
if(!is_dir($newdir))
mkdir($newdir,0777);
$dd=opendir($olddir);
while($filed=readdir($dd))
{if(is_file($olddir."/".$filed))
{
//echo "$filed<br>";
$oldfile=$olddir."/".$filed."/";
$newfile=$newdir."/".$filed."/";
$yes=copy($oldfile,$newfile);
if($yes) echo $oldfile."copy success!<br>";
else echo $oldfile."copy wrong<br>";
}
}
}
else
{
//to copy files in root directory
echo "begin copy root directory files..........<br>";
if($file!="install.php")
{if($file!="sql.php")
{
$newfile=$new."/".$file;
$oldfile=$old."/".$file;
$newdir=$new.$file;
$yes=copy($oldfile,$newfile);
if($yes) echo $file."copy success!<br>";
else echo $file."copy wrong<br>";
}
}
}
}
}
closedir($d);
}
//*************************************
//***********************function end**************
//********************************
//*******test below
//old is this install file directory
$old=".";
$new="../fenzhan/";
dircopy($old,$new);
?>
FTP函数不难,.