Advertisement
Guest User

Untitled

a guest
Nov 28th, 2016
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. <?php
  2. ini_set("display_errors", "1");
  3. error_reporting(E_ALL);
  4.  
  5. $ftp_server = "server_address";
  6. $ftp_username = "username";
  7. $ftp_userpass = "password";
  8.  
  9. $ftp_conn = ftp_connect($ftp_server) or die("Could not connect to $ftp_server");
  10. $login = ftp_login($ftp_conn, $ftp_username, $ftp_userpass);
  11.  
  12. $src_file = 'source_file'; //File to write
  13. $dest_file = 'server_file'; //File to download
  14.  
  15. $data_file = fopen($src_file, 'w');
  16.  
  17. // Initate the download
  18. $ret = ftp_nb_fget($ftp_conn, $data_file, $dest_file, FTP_BINARY);
  19.  
  20. while ($ret == FTP_MOREDATA) {
  21.  
  22. // Do whatever you want
  23. echo ".";
  24.  
  25. // Continue downloading...
  26. $ret = ftp_nb_continue($ftp_conn);
  27. }
  28. if ($ret != FTP_FINISHED) {
  29. echo "There was an error downloading the file...";
  30. exit(1);
  31. }
  32. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement