FTP file transfers

Hi everyone!

I need to copy some config text files (generated using SC) to an external asterisk server to upgrade changes. Using PHP FTP connection commands didnt work.

Here is my code:

$ftp_username = {user}; // User name
$ftp_userpass = {pass}; // User password
$ftp_server = {url}; // Destination server IP

// Set up basic connection
$conn_id = ftp_connect($ftp_server);

// Login with username and password
$login_result = ftp_login($conn_id, $ftp_username, $ftp_userpass);

// Check connection
if ((!$conn_id) || (!$login_result)) {
echo "FTP connection has failed! ";
echo “Attempted to connect to $ftp_server for user $ftp_username”;
}
else {
echo “Connected to $ftp_server, for user $ftp_username”;
}

Always post “FTP connection has failed”… User OK, Pass OK, Windows Firewall checked OK and allow FTP private and public.

How could I get this?

Any tips? Thank you

I just tried your code against one of my FTP servers and it worked fine!

However, there is one thing that you should be aware of, which may be causing your problem:

When specifying your server, do not include the “ftp://” prefix, so instead of for example “ftp://test-site.com”, just specify the server as “test-site.com”. If you include the prefix, you will not get the connection.

If this does not help, proceed with step a to e above – and make really sure that the credentials are correct.