I am using ftp_get to fetch a file from another ftp server.
My code works perfectly on my local WAMP server, but when I apply it to my actual web hosting, the connection fails.
$conn = ftp_connect('ftp.server.com') or die('Could not connect');
ftp_login($conn,'myusername','mypassword');
$local_file = 'new/two.txt';
$remote_file = 'games/minecraft/craftbukkit/plugins/VisitCounter/config.yml';
$get = ftp_get($conn,$local_file,$remote_file,FTP_ASCII);
if ($get){
echo 'Connection Successful';
} else{
echo 'Connection failure';
}
exec($get);
ftp_close($conn);
I'm thinking that something required to establish a ftp connection must be disabled on my web server.
Can any of you assist?
Thanks,
Jared
Your server is not in a passive mode,You just need to turns on passive mode of your server using the php function as :-
$conn_id = ftp_connect($ftp_server);
// login with username and password
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
// turn passive mode on
$ps = ftp_pasv($conn_id, true);
Hope it will work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With