PHP 8.5.0 Alpha 4 available for testing

Voting

: five minus two?
(Example: nine)

The Note You're Voting On

bintjes at gmail dot com
16 years ago
I've seen two notes about a "ftp_copy" function but i think there's a misinterpretation about what an "ftp_copy" function should do. For me , it should be something like an ftp_rename that would keep the orginal file and clone it somewhere else on the same ftp server, as for them they consider its purpose is to copy a local file to a distant ftp ..well .. as in FTP protocol there's no such thing as an FTP COPY command anyway, i think you're free to interpret it as you want.
So here's my solution using ftp_put and ftp_get ..

<?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 ;
}
?>

<< Back to user notes page

To Top