note 40954 deleted from function.ftp-get by didou
| From: | didou@php.net | Date: | Sun, 16 Jan 2005 05:35:46 +0000 |
| Subject: | note 40954 deleted from function.ftp-get by didou | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-83371@lists.php.net to get a copy of this message | ||
Note Submitter: loki at legion-of-fortitude dot net
----
A little more trouble shooting in this version. (we used this to download a linux patch for our game
server preventing manual down/uploads)
<?php
// define some variables
$local_file = 'cod-lnxded-1.3.large.tar.bz2';
$server_file = 'pub/3dgamers4/games/callofduty/cod-lnxded-1.3.large.tar.bz2';
$ftp_server = "3dgamers.in-span.net";
$ftp_user_name = "anonymous";
$ftp_user_pass = "guest@all.com";
// set up basic connection
if ($conn_id = ftp_connect($ftp_server)) {
echo "Connected to ".$ftp_server."";
}else{
echo "Can't connect to ".$ftp_server."";
exit();
}
// login with username and password
if ($login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass)) {
echo "Logged on to ".$ftp_server."<br>User:
".$ftp_user_name."<br>Pass: ".$ftp_user_pass."";
}else{
echo "Can't logon as User: ".$ftp_user_name."<br>Pass:
".$ftp_user_pass."";
exit();
}
// 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";
exit();
}
// close the connection
if ($conn_id) {
ftp_close($conn_id);
}
?>