如何使用PHP复制FTP文件 [英] How To Copy Files Around FTP Using PHP

查看:102
本文介绍了如何使用PHP复制FTP文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



eg



p> 复制此档案:httpdocs / user_images / Services /档案1.jpg

致: httpdocs / user_images / folder11



我尝试过使用ftp_fput,但我没有任何运气。

解决方案

ftp_put 的手册页 PHP.net

 <?php 
/ / bool ftp_copy(resource $ ftp_stream,string $ initialpath,string $ newpath,string $ imagename)
函数ftp_copy($ conn_distant,$ pathftp,$ pathftpimg,$ img){
// recupere l' (ftp_get($ conn_distant,TEMPFOLDER。$ img,$ pathftp。'/'。$ img,FTP_BINARY)){
if(ftp_put($ conn_distant, $ pathftpimg。 '/'。$ IMG ,TEMPFOLDER。$ img,FTP_BINARY)){
unlink(TEMPFOLDER。$ img);
} else {
return false;
}

} else {
return false;
}
返回true;
}
?>


I am tring to copy a file from one folder to another using the php ftp functions.

e.g

Copy This File: httpdocs/user_images/Services/File 1.jpg

To: httpdocs/user_images/folder11

i have tried to use ftp_fput but i am not have any luck with it.

解决方案

From the manual page on ftp_put on PHP.net:

<?php 
// bool ftp_copy  ( resource $ftp_stream  , string $initialpath, string $newpath, string $imagename ) 
function ftp_copy($conn_distant , $pathftp , $pathftpimg ,$img){ 
        // on recupere l'image puis on la repose dans le nouveau folder 
        if(ftp_get($conn_distant, TEMPFOLDER.$img, $pathftp.'/'.$img ,FTP_BINARY)){ 
                if(ftp_put($conn_distant, $pathftpimg.'/'.$img ,TEMPFOLDER.$img , FTP_BINARY)){ 
                        unlink(TEMPFOLDER.$img) ;                                              
                } else{                                
                        return false; 
                } 

        }else{ 
                return false ; 
        } 
        return true ; 
} 
?>

这篇关于如何使用PHP复制FTP文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆