Upload files to remote server

To upload files on remote server php built-in function ftp_put() is used.
Just follow these simple steps.

1. Make ftp connection with remote server.
2. Login with remote server username and Password.
3. Use ftp_put() function

The syntax of ftp_put() function :

ftp_put($ftp_conn,$remote_file,$local_file,mode);

Here is the example code :

  //Change this
  $server = 'anysite.com';
  $username = 'username';
  $password = 'password';
  $local_file = 'original.jpg';
  $remote_file = 'uploaded.jpg';

  $conn = ftp_connect($server);
  $login = ftp_login($conn, $username, $password);

  ftp_put($conn, $remote_file, $local_file, FTP_ASCII);
  ftp_close($conn);

Upload files to remote server Upload files to remote server Reviewed by JS Pixels on June 15, 2011 Rating: 5

No comments:

Altaf Web. Powered by Blogger.