简体   繁体   中英

Transfer a file via FTP to another server using PHP

I have a file in my server and I want to transfer it to another server using FTP. The file I have is in the same folder as my PHP page.

The code I am using does not work

$my_connection = ftp_connect("tel.bpo.fr", 21) or exit('Erreur : connexion au serveur FTP impossible.');
ftp_login($my_connection, "AD_185", "UYTREE");

$from = "test.csv" ; 
$to = "/entree/test.csv" ; 

if ($my_connection && ftp_put($my_connection, $to, $from,  FTP_BINARY)){
    echo "good <br/>" ;
}else {
    echo "erreur";
}

What does not work? Looks like Windows / Paths... To enable ftp on Windows you have to add the line:

extension=php_ftp.dll

to your php.ini to resolve PHP errors that tell you PHP FTP functions are not defined; the line isn't in there (where, many things are and are just commented out).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM