Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- ini_set("display_errors", "1");
- error_reporting(E_ALL);
- $ftp_server = "server_address";
- $ftp_username = "username";
- $ftp_userpass = "password";
- $ftp_conn = ftp_connect($ftp_server) or die("Could not connect to $ftp_server");
- $login = ftp_login($ftp_conn, $ftp_username, $ftp_userpass);
- $src_file = 'source_file'; //File to write
- $dest_file = 'server_file'; //File to download
- $data_file = fopen($src_file, 'w');
- // Initate the download
- $ret = ftp_nb_fget($ftp_conn, $data_file, $dest_file, FTP_BINARY);
- while ($ret == FTP_MOREDATA) {
- // Do whatever you want
- echo ".";
- // Continue downloading...
- $ret = ftp_nb_continue($ftp_conn);
- }
- if ($ret != FTP_FINISHED) {
- echo "There was an error downloading the file...";
- exit(1);
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement