Saving a remote file via FTP with file_put_contents() : FTP Functions « Network « PHP






Saving a remote file via FTP with file_put_contents()

 
$page = file_get_contents('page-template.html');

$page = str_replace('{page_title}', 'Welcome', $page);

if (date('H' >= 12)) {
    $page = str_replace('{color}', 'blue', $page);
} else {
    $page = str_replace('{color}', 'green', $page);
}


$page = str_replace('{name}', $_SESSION['username'], $page);

file_put_contents('ftp://name:password@ftp.example.com/welcome.html', $page);
  
  








Related examples in the same category

1.FTP Functions
2.Write to file with ftp functions
3.Write to remote file on a ftp server
4.Using a password with FTP or HTTP
5.ftp put
6.use the ftp_* functions to upload a single file to an FTP server.