Write to file with ftp functions : FTP Functions « Network « PHP






Write to file with ftp functions

 
<?php

$file_name = "index.php";
$fp = fopen($file_name, 'r');
if ($fp) {
  $data = fread($fp, filesize($file_name));
  fclose($fp);

  $file_name = "ftp://user:pass@ftp.somedomain.com/home/user/$file_name"; 
  $fp = fopen($file_name, 'wt');
  if ($fp) {
    echo 'writing data';
    fwrite($fp, $data);
    fclose($fp);
  }
}
?>
  
  








Related examples in the same category

1.FTP Functions
2.Write to remote file on a ftp server
3.Saving a remote file via FTP with file_put_contents()
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.