Write to remote file on a ftp server : FTP Functions « Network « PHP






Write to remote file on a ftp server

 
<?php
$file_name = "data.txt";
$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 file with ftp functions
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.