<?php
$sourcefile = ‘sendfile.txt’;
$dest_file = ‘readme.txt’;
$ftp_server=”;
$ftp_user_name=”;
$ftp_user_pass=”;
$ftp_con = ftp_connect($ftp_server);
$login_result = ftp_login($ftp_con, $ftp_user_name, $ftp_user_pass);
if (ftp_put($ftp_con, $dest_file, $sourcefile, FTP_ASCII)) {
echo “Successfully uploaded $file\n”;
} else {
echo “FTP upload Failed\n”;
}
ftp_close($conn_id);
Above script will first make connection to the ftp server using ftp_connect php function. Once the connection is created, you just need to pass ftp login details in ftp_login php function. Finally the ftp_put php function will perform file sending task.