Created
April 25, 2016 15:30
-
-
Save wp-kitten/cbb3b0572a640b602fc5e3975f74009d to your computer and use it in GitHub Desktop.
Get file from remote password protected ftp url
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// define some variables | |
$local_file = 'local.zip'; | |
$server_file = 'server.zip'; | |
// set up basic connection | |
$conn_id = ftp_connect($ftp_server); | |
// login with username and password | |
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass); | |
// try to download $server_file and save to $local_file | |
if (ftp_get($conn_id, $local_file, $server_file, FTP_BINARY)) { | |
echo "Successfully written to $local_file\n"; | |
} else { | |
echo "There was a problem\n"; | |
} | |
// close the connection | |
ftp_close($conn_id); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment