Advertisement
Guest User

Untitled

a guest
Apr 24th, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. <?php
  2. // Connect and login to FTP server
  3. $ftp_server = "hostname";
  4. $ftp_username ="username";
  5. $ftp_userpass = "password";
  6. $includes = "/directory/";
  7. $ftp_conn = ftp_connect($ftp_server) or die("Could not connect to $ftp_server");
  8. $login = ftp_login($ftp_conn, $ftp_username, $ftp_userpass);
  9.  
  10. // Get file list
  11. $contents = ftp_nlist($conn_id, $includes);
  12.  
  13. // Loop through for file 1
  14. foreach ($contents as $file) {
  15. $local_file = '/path/to/file.php';
  16. $server_file = '/path/to/file.php';
  17. ftp_get($conn_id, $local_file, $server_file, FTP_BINARY);
  18. }
  19.  
  20. // Loop through for file 2
  21. foreach ($contents as $file) {
  22. $local_file = '/path/to/file.php';
  23. $server_file = '/path/to/file.php';
  24. ftp_get($conn_id, $local_file, $server_file, FTP_BINARY);
  25. }
  26.  
  27. // close connection
  28. ftp_close($ftp_conn);
  29. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement